Boost C++ Libraries: Ticket #9944: Regression test relies on undefined compiler behavior https://svn.boost.org/trac10/ticket/9944 <p> libs/utility/numeric_traits_test.cpp generates values complement_traits&lt;Number&gt;::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++). </p> <p> The only use for the clever templates, as the comment in the file says, is for "platforms without &lt;limits&gt; support" so my proposed fix is: </p> <p> #ifndef BOOST_NO_LIMITS template &lt;class Number&gt; struct complement_traits { </p> <blockquote> <p> BOOST_STATIC_CONSTANT(Number, min = std::numeric_limits&lt;Number&gt;::min()); BOOST_STATIC_CONSTANT(Number, max = std::numeric_limits&lt;Number&gt;::max()); </p> </blockquote> <p> }; #else [SNIP] All of the other template definitions for complement_traits, complement_traits_aux, etc. #endif </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/9944 Trac 1.4.3 chris.cooper@… Wed, 23 Apr 2014 21:02:30 GMT <link>https://svn.boost.org/trac10/ticket/9944#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9944#comment:1</guid> <description> <p> std::numeric_limits&lt;Number&gt;::min() and std::numeric_limits&lt;Number&gt;::max() are not constant expressions unless c++11 is specified, so a better fix is </p> <pre class="wiki">#if !defined(BOOST_NO_LIMITS) &amp;&amp; !defined(BOOST_NO_CXX11_CONSTEXPR) template &lt;class Number&gt; struct complement_traits { BOOST_STATIC_CONSTANT(Number, min = std::numeric_limits&lt;Number&gt;::min()); BOOST_STATIC_CONSTANT(Number, max = std::numeric_limits&lt;Number&gt;::max()); }; #else [SNIP] All of the other template definitions for complement_traits, complement_traits_aux, etc. #endif </pre> </description> <category>Ticket</category> </item> <item> <author>chris.cooper@…</author> <pubDate>Thu, 24 Apr 2014 15:06:48 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/9944#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9944#comment:2</guid> <description> <p> Kim Barrett suggested using boost::integer_traits&lt;Number&gt;::const_min / const_max </p> <p> It's not entirely clear what this file (numeric_traits_test.cpp) is testing - there is so much template stuff at the top, and then it looks like a lot of the tests are simply verifying that the templates work. There is data sent to std::cout which is perhaps helpful to developers, but not in an automated regression test. It appears the only thing that it tests (from an automated test point of view) is boost::detail::numeric_distance()? </p> </description> <category>Ticket</category> </item> <item> <author>Niklas Angare <li51ckf02@…></author> <pubDate>Thu, 26 Jun 2014 21:54:56 GMT</pubDate> <title>owner, component changed https://svn.boost.org/trac10/ticket/9944#comment:3 https://svn.boost.org/trac10/ticket/9944#comment:3 <ul> <li><strong>owner</strong> changed from <span class="trac-author">René Rivera</span> to <span class="trac-author">No-Maintainer</span> </li> <li><strong>component</strong> <span class="trac-field-old">Regression Testing</span> → <span class="trac-field-new">utility</span> </li> </ul> Ticket