[Bug libstdc++/67214] New: undefined behaviour in std::num_get::_M_extract_int()
malcolm.parsons at gmail dot com
gcc-bugzilla@gcc.gnu.org
Fri Aug 14 11:33:00 GMT 2015
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67214
Bug ID: 67214
Summary: undefined behaviour in std::num_get::_M_extract_int()
Product: gcc
Version: 4.8.4
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: malcolm.parsons at gmail dot com
Target Milestone: ---
$ cat num_get.cpp
#include <iostream>
#include <sstream>
#include <boost/math/special_functions/nonfinite_num_facets.hpp>
int main()
{
std::locale loc;
auto loc1 = std::locale{loc, new boost::math::nonfinite_num_get<char>};
std::locale::global(loc1);
std::string s{"-1"};
std::istringstream is{s};
bool v;
is >> v;
std::cout << v << '\n';
return 0;
}
$ clang++-3.6 --std=c++11 -fsanitize=undefined num_get.cpp -o num_get -O2
$ ./num_get
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/locale_facets.tcc:468:6:
runtime error: negation of -9223372036854775808 cannot be represented in type
'long'; cast to an unsigned type to negate this value to itself
line 468 is the third line below:
const __unsigned_type __max =
(__negative && __gnu_cxx::__numeric_traits<_ValueT>::__is_signed)
? -__gnu_cxx::__numeric_traits<_ValueT>::__min
: __gnu_cxx::__numeric_traits<_ValueT>::__max;
I'm reporting against libstdc++ 4.8.4, but these lines have not changed in git
master.
More information about the Gcc-bugs
mailing list