Subject: [Boost-bugs] [Boost C++ Libraries] #12941: Ignore return value from BOOST_INTERLOCKED_EXCHANGE
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2017-03-30 10:03:51
#12941: Ignore return value from BOOST_INTERLOCKED_EXCHANGE
------------------------------+----------------------
Reporter: mattyclarkson@⦠| Owner: anthonyw
Type: Bugs | Status: new
Milestone: To Be Determined | Component: thread
Version: Boost 1.63.0 | Severity: Problem
Keywords: |
------------------------------+----------------------
Warnings are created by MinGW for ignoring the return value in
`boost::detail::interlocked_read_acquire`:
{{{
namespace boost
{
namespace detail
{
inline long interlocked_read_acquire(long volatile* x)
BOOST_NOEXCEPT
{
return BOOST_INTERLOCKED_COMPARE_EXCHANGE(x,0,0);
}
inline void* interlocked_read_acquire(void* volatile* x)
BOOST_NOEXCEPT
{
return BOOST_INTERLOCKED_COMPARE_EXCHANGE_POINTER(x,0,0);
}
inline void interlocked_write_release(long volatile* x,long value)
BOOST_NOEXCEPT
{
BOOST_INTERLOCKED_EXCHANGE(x,value);
}
inline void interlocked_write_release(void* volatile* x,void*
value) BOOST_NOEXCEPT
{
BOOST_INTERLOCKED_EXCHANGE_POINTER(x,value);
}
}
}
}}}
My proposed fix it to cast the return value to `void`:
{{{
namespace boost
{
namespace detail
{
inline long interlocked_read_acquire(long volatile* x)
BOOST_NOEXCEPT
{
return BOOST_INTERLOCKED_COMPARE_EXCHANGE(x,0,0);
}
inline void* interlocked_read_acquire(void* volatile* x)
BOOST_NOEXCEPT
{
return BOOST_INTERLOCKED_COMPARE_EXCHANGE_POINTER(x,0,0);
}
inline void interlocked_write_release(long volatile* x,long value)
BOOST_NOEXCEPT
{
(void)BOOST_INTERLOCKED_EXCHANGE(x,value);
}
inline void interlocked_write_release(void* volatile* x,void*
value) BOOST_NOEXCEPT
{
(void)BOOST_INTERLOCKED_EXCHANGE_POINTER(x,value);
}
}
}
}}}
It would also be possible to use `static_cast<void>(...)`:
{{{
namespace boost
{
namespace detail
{
inline long interlocked_read_acquire(long volatile* x)
BOOST_NOEXCEPT
{
return BOOST_INTERLOCKED_COMPARE_EXCHANGE(x,0,0);
}
inline void* interlocked_read_acquire(void* volatile* x)
BOOST_NOEXCEPT
{
return BOOST_INTERLOCKED_COMPARE_EXCHANGE_POINTER(x,0,0);
}
inline void interlocked_write_release(long volatile* x,long value)
BOOST_NOEXCEPT
{
static_cast<void>(BOOST_INTERLOCKED_EXCHANGE(x,value));
}
inline void interlocked_write_release(void* volatile* x,void*
value) BOOST_NOEXCEPT
{
static_cast<void>(BOOST_INTERLOCKED_EXCHANGE_POINTER(x,value));
}
}
}
}}}
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/12941> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-03-30 10:09:48 UTC