Reputation: 191
I have used Mingw-w64
compiler in my project. Now I am compiling the project with MSVC2015
. The following line gives an error:
constexpr double pi = 4*std::atan(1);
error:
error: C2131: expression did not evaluate to a constant
However it compiled in mingw without any problems.
Upvotes: 1
Views: 1205
Reputation: 48998
MSVC is right in this case, from [constexpr.functions]p1
This document explicitly requires that certain standard library functions are constexpr. An implementation shall not declare any standard library function signature as constexpr except for those where it is explicitly required.
As you can see from the last sentence that I highlighted, an implementation is not allowed to declare a function constexpr
if the standard doesn't say so.
Now does the standard say that atan
is constexpr
? No, as can be seen from the signature in [c.math]:
float atan(float x); // see [library.c] double atan(double x);
Upvotes: 3