Subject: [Boost-bugs] [Boost C++ Libraries] #11286: Code in boost/endian/buffers.hpp violates old C++03 Standard
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2015-05-11 20:06:23
#11286: Code in boost/endian/buffers.hpp violates old C++03 Standard
------------------------------+------------------------
Reporter: Sergey.Sprogis@⦠| Owner: bemandawes
Type: Bugs | Status: new
Milestone: To Be Determined | Component: endian
Version: Boost 1.58.0 | Severity: Problem
Keywords: |
------------------------------+------------------------
1. Description of the failure.
endian/test/endian_in_union_test.cc fails with Oracle Studio C++ compiler
on Solaris producing bunch of similar error message similar shown below::
"CC" -KPIC -DBOOST_ALL_NO_LIB=1 -DNDEBUG -I"../../.." -o
"../../../bin.v2/libs/endian/test/endian_in_union_test.test/sun/release
/stdlib-sun-stlport/threading-multi/endian_in_union_test.o"
"endian_in_union_test.cpp"
"endian_in_union_test.cpp", line 77: Error: A union member cannot have a
user-defined assignment operator.
2. Cause of the failure.
The failure can be demonstrated with 4 lines small independent t.cpp
test:
class endian_buffer {
endian &endian_buffer = (int val);
};
union U { endian_buffer m; };
CC -c t.cpp
"t.cc", line 4: Error: A union member cannot have a user-defined
assignment operator.
Small test above has been extracted and slightly modified from the
code shown below located under boost/endian/buffers.hpp
template <typename T, std::size_t n_bits>
class endian_buffer< order::big, T, n_bits, align::no >
{
....
endian_buffer & operator=(T val) BOOST_NOEXCEPT // Line 358
C++03 Standard explicitly rejects the use of classes with user-defined
assignment operators in unions:
C++2003 9.5 [class.union]p1
An object of a class with a ... non-trivial copy assignment operator
(13.5.3, 12.8) cannot be a member of a union.
In C++11 the code is valid, as a result of apply "Unrestricted
Unions" feature.
But since it is a C++11 feature, it should not affect C++03
compilation.
Seems like g++ has a bug here compiling this code successfully in both
C++03 and C++11 mode.
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/11286> 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-02-16 18:50:18 UTC