https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114363

Harald van Dijk <harald at gigawatt dot nl> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |harald at gigawatt dot nl

--- Comment #1 from Harald van Dijk <harald at gigawatt dot nl> ---
This is, I believe, correct. Before C++11, calling std::pow with float and int
arguments, it returned a float. As of C++11, it returns a double.

If the result of pow(x,2) is immediately converted to float, then it is a valid
optimisation to convert it to x*x: that is guaranteed to produce the exact same
result. But if it isn't, then converting to x*x loses accuracy and alters the
result.

You can call std::powf instead of std::pow to avoid the promotion to double.

Reply via email to