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

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Jan 3 08:27:10 PST 2019


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: unassignedclangbugs at nondot.org
          Reporter: shachar at shemesh.biz
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190103/032060a8/attachment.html>


More information about the llvm-bugs mailing list