[Llvm-bgq-discuss] Bug when using boost::numeic_cast
Godenschwager, Christian
christian.godenschwager at fau.de
Thu Dec 3 10:35:01 CST 2015
Hi everyone!
First let me say a big thank you to all the people who have put some effort
into bgclang! It is just great to have clang available on the BG/Q platform.
While compiling and running our C++ code using bgclang I stumbled upon a
problem using boost::numeric_cast. The code
#include <iostream>
#include <boost/numeric/conversion/cast.hpp>
int main()
{
long l = 0;
int i = boost::numeric_cast<int>( l );
std::cout << l << " " << i << std::endl;
}
results in a negative underflow exception when compiling it with bgclang. I
investigated a bit and the minimal example I could come up with not using
boost is
#include <iostream>
#include <limits>
template< typename T >
class Dummy
{
public:
static T lowest() { return std::numeric_limits<T>::min(); }
};
int main()
{
std::cout << static_cast<long>( Dummy<int>::lowest() ) << std::endl;
std::cout << static_cast<long>( Dummy<int>::lowest() ) -
static_cast<long>(1.0) << std::endl;
}
Which prints
2147483648
2147483647
but should print
-2147483648
-2147483649
The problem only occurs when using bgclang++11 while bgclang++ works fine.
Also removing the intermediate Dummy class or removing the second line in
the main function results in correct behavior. I could reproduce the wrong
behavior with versions r248407, r236977 and r232720 while r220548 works
fine. I tested on JUQUEEN.
Could anyone look into that?
All the best,
Christian
--
Dipl.-Inform. Christian Godenschwager
Universitaet Erlangen-Nuernberg
Lehrstuhl fuer Informatik 10 - Systemsimulation
Cauerstraße 11
D-91058 Erlangen
Tel: +49 9131 85 67292
Fax: +49 9131 85 28928
E-Mail: christian.godenschwager at fau.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 6266 bytes
Desc: not available
URL: <http://lists.alcf.anl.gov/pipermail/llvm-bgq-discuss/attachments/20151203/150a79a5/attachment.bin>
More information about the llvm-bgq-discuss
mailing list