- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hey there!
With g++ from GCC 4.8 (and probably before that as well), I can do something like:
constexpr double foo = std::floor(4.0);
With icpc 14.0 though I get this error message:
/home/milian/projects/foo.cpp(5): error: function call must have a constant value in a constant expression
constexpr double foo = std::floor(4.0);
cmath defines std::floor with _GLIBCXX_CONSTEXPR, which is set in c++config.h:
#if __cplusplus
// Macro for constexpr, to support in mixed 03/0x mode.
#ifndef _GLIBCXX_CONSTEXPR
# if __cplusplus >= 201103L
# define _GLIBCXX_CONSTEXPR constexpr
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have reproduced this problem with this small test case below. I have entered this in our internal bug tracking database as DPD200249275. Thank you for bringing this to our attention.
Judy
namespace std
{
inline constexpr float floor(float __x) {
return __builtin_floor(__x);
}
}
constexpr double floor = std::floor(4.0);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Note that e.g. also happens for std::sqrt which has a more convoluted signature in mathcalls.h. Still, in GCC I can use it in an constexpr.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page