Loading...
You are not logged-in Login/Register





  • Posts   Search Threads
  • robert.jay.gouldOctober 28, 2008 8:23 PM PDT   
    Is atomic's _internal_reference broken?

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

    When doing this:

    atomic<int> atomic_int;
    atomic_int = 5;
    const int& your_int = atomic_int._internal_reference();

    I get this error message:

    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<I,D,Step>::_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<I,D,Step>' being compiled
    1>        with
    1>        [
    1>            I=int,
    1>            D=int,
    1>            Step=1
    1>        ]

    Now I did the following const_cast to solve the issue:

    File:tbb/atomic.h
    Line: 230
        value_type& _internal_reference() const {
            return static_cast<value_type&>(const_cast<atomic_impl<I,D,Step>* >(this)->my_value);
        }

    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?



    Arch Robison (Intel)October 28, 2008 9:17 PM PDT
    Rate
     
    Re: Is atomic's _internal_reference broken?

    Thanks for reporting this.  Method atomic<T>::_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.



    robert.jay.gouldOctober 28, 2008 9:48 PM PDT
    Rate
     
    Re: Is atomic's _internal_reference broken?

    Thanks for the news! It seemed kind of fishy so I was left scratching my head there for a while.


Forum jump:  

Intel Software Network Forums Statistics

17,025 users have contributed to 48,321 threads and 172,753 posts to date.

In the past 24 hours, we have 16 new thread(s) 57 new posts(s), and 54 new user(s).

In the past 3 days, the most popular thread for everyone has been How to manage rounding by IVF ?? The most posts were made to Most likely, the issue is that The post with the most views is Optimalization of sine function\'s taylor expansion

Please welcome our newest member redfruit83


For more complete information about compiler optimizations, see our Optimization Notice.