Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.

Is atomic's _internal_reference broken?

robert_jay_gould
Beginner
275 Views

I keep getting compile errors (in VC8) when trying to use atomic's_internal_reference member (which is public).

When doing this:

[cpp]atomic atomic_int;
atomic_int = 5;
const int& your_int = atomic_int._internal_reference();[/cpp]

I get this error message:

[cpp]1>d:projectsspikeslibrariestbb21_012ossincludetbb/atomic.h(230) : error C2440: 'static_cast' : cannot convert from 'const int' to 'int &'
1>        static_cast and safe_cast to reference can only be used for valid initializations or for lvalue casts between related classes
1>        d:projectsspikeslibrariestbb21_012ossincludetbb/atomic.h(229) : while compiling class template member function 'int &tbb::internal::atomic_impl::_internal_reference(void) const'
1>        with
1>        [
1>            I=int,
1>            D=int,
1>            Step=1
1>        ]
1>        d:projectsspikeslibrariestbb21_012ossincludetbb/atomic.h(321) : see reference to class template instantiation 'tbb::internal::atomic_impl' being compiled
1>        with
1>        [
1>            I=int,
1>            D=int,
1>            Step=1
1>        ][/cpp]

Now I did the following const_cast to solve the issue:

[cpp]File:tbb/atomic.h
Line: 230
    value_type& _internal_reference() const {
        return static_cast(const_cast* >(this)->my_value);
    }[/cpp]

However... I'm not sure if that's the problem at all,

because first of all _internal_reference doesn't look like something

that should be in the public interface at all.

What's the story about this?

0 Kudos
2 Replies
ARCH_R_Intel
Employee
275 Views
Thanks for reporting this. Method atomic::_internal_reference() is an old method that once was used internally inside TBB. It was never documented. It is no longer used as far as I can tell, and we should remove it from the distribution.

0 Kudos
robert_jay_gould
Beginner
275 Views
Thanks for the news! It seemed kind of fishy so I was left scratching my head there for a while.
0 Kudos
Reply