https://bugs.llvm.org/show_bug.cgi?id=40216

            Bug ID: 40216
           Summary: sqrt not considered constexpr
           Product: clang
           Version: 7.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected], [email protected],
                    [email protected]

The following program:

#include <cmath>

static constexpr double GoldenRatio = (1 + sqrt(5.0)) / 2;

Compiles fine on g++. Clang++ does not compile it:

test.cpp:3:25: error: constexpr variable 'GoldenRatio' must be initialized by a
constant expression
static constexpr double GoldenRatio = (1 + sqrt(5.0)) / 2;
                        ^             ~~~~~~~~~~~~~~~~~~~
test.cpp:3:44: note: non-constexpr function 'sqrt' cannot be used in a constant
expression
static constexpr double GoldenRatio = (1 + sqrt(5.0)) / 2;
                                           ^
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:143:13: note: declared here
__MATHCALL (sqrt,, (_Mdouble_ __x));
            ^
1 error generated.

$ clang++ --version
clang version 7.0.0-3 (tags/RELEASE_700/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

Ran on Ubuntu 18.10

Preventing compilation of practicomp: https://github.com/practical/practicomp.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to