Opened 6 years ago

Closed 6 years ago

#12478 closed Bugs (fixed)

boost::atomic< char* > generates warning on fetch_add on gcc 4.8+

Reported by: Matt Hauck <matthauck@…> Owned by: Andrey Semashev
Milestone: To Be Determined Component: atomic
Version: Boost 1.61.0 Severity: Problem
Keywords: Cc:

Description

I have a boost::atomic< char* > object, on which I am calling fetch_add with ptrdiff_t, and apparently only on gcc 4.8+, I am getting the following warning:

In file included from /home/foo/packages/boost_1_61_0/include/boost/atomic/detail/atomic_template.hpp:25:0,
                 from /home/foo/packages/boost_1_61_0/include/boost/atomic/atomic.hpp:22,
                 from /home/foo/packages/boost_1_61_0/include/boost/atomic.hpp:12,
                 from /home/foo/code/ThingThatUsesAtomic.h:0,
/home/foo/packages/boost_1_61_0/include/boost/atomic/detail/bitwise_cast.hpp: In instantiation of ‘To boost::atomics::detail::bitwise_cast(const From&) [with To = char*; From = long unsigned int]’:
/home/foo/packages/boost_1_61_0/include/boost/atomic/detail/atomic_template.hpp:449:59:   required from ‘T* boost::atomics::detail::base_atomic<T*, void*>::fetch_add(boost::atomics::detail::base_atomic<T*, void*>::difference_type, boost::memory_order) volatile [with T = char; boost::atomics::detail::base_atomic<T*, void*>::value_type = char*; boost::atomics::detail::base_atomic<T*, void*>::difference_type = long int]’
[ actual code references redacted ... ]
/home/foo/packages/boost_1_61_0/include/boost/atomic/detail/bitwise_cast.hpp:41:5: warning: casting ‘char*’ to ‘char&’ does not dereference pointer

Change History (2)

comment:1 by Andrey Semashev, 6 years ago

Owner: changed from timblechmann to Andrey Semashev

comment:2 by Andrey Semashev, 6 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.