Subject: [Boost-bugs] [Boost C++ Libraries] #9925: operators_test.cpp test_left_shiftable is failing due to invalid parameters
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-04-18 18:28:38
#9925: operators_test.cpp test_left_shiftable is failing due to invalid parameters
------------------------------+--------------------------------
Reporter: chris.cooper@⦠| Owner: grafik
Type: Bugs | Status: new
Milestone: To Be Determined | Component: Regression Testing
Version: Boost 1.54.0 | Severity: Problem
Keywords: |
------------------------------+--------------------------------
In libs/utility/operators_test.cpp, test_left_shiftable is checking
whether one random value shifted by a second random value, is the same
whether called directly or via the Wrapper2<> and Wrapper1<> template
classes.
However, according to C++ ISO specification (INCITS/ISO/IEC
14882-2011\[2012\]), section 5.8.2 (which I don't have, but is referenced
at http: / / msdn.microsoft.com/en-us/library/336xbhcz.aspx), left-
shifting a signed value has undefined behavior (which is much more
unpleasant than implementation-defined behavior) if the result doesn't fit
in an unsigned value of the same size.
With the clang compiler that comes with Xcode 5.1 ("Apple LLVM version 5.1
(clang-503.0.38) (based on LLVM 3.4svn)"), the results of such left-shifts
are seemingly random - this code:
{{{
long b1 = 48271;
int s = 1291394886;
std::cout << (b1 << s) << std::endl;
std::cout << (b1 << s)<< std::endl;
std::cout << (b1 << s)<< std::endl;
}}}
prints three different numbers.
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/9925> 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