This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/49813] [C++0x] sinh vs asinh vs constexpr
- From: "vincenzo.innocente at cern dot ch" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 22 Jul 2011 11:08:03 +0000
- Subject: [Bug c++/49813] [C++0x] sinh vs asinh vs constexpr
- Auto-submitted: auto-generated
- References: <bug-49813-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49813
--- Comment #8 from vincenzo Innocente <vincenzo.innocente at cern dot ch> 2011-07-22 11:06:41 UTC ---
what about other "new C99 functions" such as
cexprMath.cpp:16:64: error: 'float std::nextafter(float, float)' is not
'constexpr'
cexprMath.cpp:17:58: error: 'float std::trunc(float)' is not 'constexpr'
cexprMath.cpp:18:48: error: 'float std::lgamma(float)' is not 'constexpr'
cexprMath.cpp:19:46: error: 'float std::erfc(float)' is not 'constexpr'
?
have not tested all (yet).
from
#include <cmath>
struct foo {
static constexpr float a = std::cos(3.);
static constexpr float c = std::exp(3.);
static constexpr float d = std::log(3.);
static constexpr float e1 = std::asin(1.);
static constexpr float h = std::sqrt(.1);
static constexpr float p = std::pow(1.3,-0.75);
static constexpr float es = std::sinh(1.);
static constexpr float ec = std::cosh(1.);
static constexpr float et = std::tanh(1.);
static constexpr float zs = std::asinh(1.2);
static constexpr float zc = std::acosh(1.2);
static constexpr float zt = std::atanh(.5);
static constexpr float pi1 =std::nextafter(std::cos(-1.f),0.f);
static constexpr float three =std::trunc(std::cos(-1.f));
static constexpr float l0 = std::lgamma(0.45f);
static constexpr float er = std::erfc(0.45f);
};
as we are on the subject:
if the argument of the function is invalid such as
static constexpr float nan1 = std::asin(1.45f);
static constexpr float nan2 = std::sqrt(-1.45f);
I get exactly the same error as above which is a bit confusing
cexprMath.cpp:20:48: error: call to non-constexpr function 'float
std::asin(float)'
cexprMath.cpp:20:48: error: field initializer is not constant
cexprMath.cpp:21:49: error: call to non-constexpr function 'float
std::sqrt(float)'
cexprMath.cpp:21:49: error: field initializer is not constant
(the test of the message has changed between 4.6 and 4.7)