octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Undefined behavior sanitizing with Clang


From: Mike Miller
Subject: Re: Undefined behavior sanitizing with Clang
Date: Mon, 18 Nov 2013 17:49:26 -0500

On Mon, Nov 18, 2013 at 23:27:58 +0100, Philipp Kutin wrote:
> Right now, I'm a bit confused seeing code like this:
>
>       if (xisint (btmp))
>         result(i) = std::pow (a, static_cast<int> (btmp));
>       else
>         result(i) = std::pow (a, btmp);
>
> The assumption here seems to be that "std::pow(T, int)" will yield a
> different result than "std::pow(T, double)" when given an
> integer-valued second argument. Why?

This is to make use of gcc's std::pow integer specialization, which
does indeed yield a different result when it is available:

  
https://github.com/mirrors/gcc/blob/master/libstdc%2B%2B-v3/include/c_global/cmath#L414

This came up on the maintainers list some months ago when it was
noticed that this specialization goes away when using g++ -std=c++11,
see the following discussions and bug report:

http://octave.1599824.n4.nabble.com/round-off-error-in-std-pow-std-complex-lt-T-gt-double-in-C-11-td4649063.html
http://octave.1599824.n4.nabble.com/Welcome-C-11-td4647840.html#a4647903
https://savannah.gnu.org/bugs/?38142

-- 
mike


reply via email to

[Prev in Thread] Current Thread [Next in Thread]