[llvm-bugs] [Bug 40216] sqrt not considered constexpr

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Jan 3 10:30:46 PST 2019


Richard Smith <richard-llvm at metafoo.co.uk> changed:

           What    |Removed                     |Added
         Resolution|---                         |LATER
             Status|NEW                         |RESOLVED

--- Comment #1 from Richard Smith <richard-llvm at metafoo.co.uk> ---
This is a GCC bug; ::sqrt and std::sqrt are not constexpr in any C++ standard.
See [cmath.syn] (http://eel.is/c++draft/cmath.syn):

  float sqrt(float x);  // see [library.c]
  double sqrt(double x);
  long double sqrt(long double x);  // see [library.c]
  float sqrtf(float x);
  long double sqrtl(long double x);

... and also [constexpr.functions]/1

  "An implementation shall not declare any standard library function signature
as constexpr except for those where it is explicitly required."

... which means we are not even permitted to treat sqrt as constexpr as an
extension (which is why this is a GCC bug rather than a GCC extension).

The latest work towards making some of <cmath> constexpr is
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0533r3.pdf -- and even
that will not make sqrt constexpr yet.

Resolving LATER: constexpr sqrt (and friends) may well end up being part of

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190103/5ff7eb2c/attachment.html>

More information about the llvm-bugs mailing list