[Llvm-bgq-discuss] Bug when using boost::numeic_cast

Hal Finkel hfinkel at anl.gov
Thu Dec 3 19:53:36 CST 2015


Hi Christian,

Thanks for the report! I'll look into the problem.

 -Hal

----- Original Message -----
> From: "Christian Godenschwager" <christian.godenschwager at fau.de>
> To: llvm-bgq-discuss at lists.alcf.anl.gov
> Sent: Thursday, December 3, 2015 10:35:01 AM
> Subject: [Llvm-bgq-discuss] Bug when using boost::numeic_cast
> 
> 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
> 
> 
> 
> _______________________________________________
> llvm-bgq-discuss mailing list
> llvm-bgq-discuss at lists.alcf.anl.gov
> https://lists.alcf.anl.gov/mailman/listinfo/llvm-bgq-discuss
> 

-- 
Hal Finkel
Assistant Computational Scientist
Leadership Computing Facility
Argonne National Laboratory


More information about the llvm-bgq-discuss mailing list