Subject: [Boost-bugs] [Boost C++ Libraries] #9944: Regression test relies on undefined compiler behavior
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-04-23 18:24:48
#9944: Regression test relies on undefined compiler behavior
------------------------------+--------------------------------
Reporter: chris.cooper@⦠| Owner: grafik
Type: Bugs | Status: new
Milestone: To Be Determined | Component: Regression Testing
Version: Boost 1.54.0 | Severity: Problem
Keywords: |
------------------------------+--------------------------------
libs/utility/numeric_traits_test.cpp generates values
complement_traits<Number>::min using a clever recursive template, but that
template relies on left-shifting a negative value, and according to the
C++11 standard thatâs a no-no (âthe behavior is undefinedâ) which means
itâs not a constant expression, which means it canât be calculated at
compile time, which means the BOOST_STATIC_ASSERT in line 332 wonât
compile, saying âstatic_assert expression is not an integral constant
expressionâ (Iâm using clang++).
The only use for the clever templates, as the comment in the file says, is
for "platforms without <limits> support" so my proposed fix is:
#ifndef BOOST_NO_LIMITS
template <class Number> struct complement_traits
{
BOOST_STATIC_CONSTANT(Number, min =
std::numeric_limits<Number>::min());
BOOST_STATIC_CONSTANT(Number, max =
std::numeric_limits<Number>::max());
};
#else
[SNIP] All of the other template definitions for complement_traits,
complement_traits_aux, etc.
#endif
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/9944> 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:16 UTC