[cfe-users] Does clang++ with libc++ support constexpr math function
Guo, Gcwenken
gcwenken.guo at ttu.edu
Mon Sep 1 12:59:34 PDT 2014
I know that g++ support constexpr math function. I want to do that on clang++. So I write a simple code.
#include<iostream>
#include<cmath>
int main()
{
constexpr auto a(std::floor(4.3));
std::cout<<a<<std::endl;
}
and then use clang++-libc++ -std=c++1y to compile it and the get the following error:
error: constexpr variable 'a' must be initialized by a constant expression
constexpr auto a(std::floor(4.3));
^ ~~~~~~~~~~~~~~~
note: non-constexpr function 'floor' cannot be used in a constant expression
constexpr auto a(std::floor(4.3));
^
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:184:14: note: declared here
__MATHCALLX (floor,, (_Mdouble_ __x), (__const__));
^
/usr/include/math.h:58:26: note: expanded from macro '__MATHCALLX'
__MATHDECLX (_Mdouble_,function,suffix, args, attrib)
^
/usr/include/math.h:60:22: note: expanded from macro '__MATHDECLX'
__MATHDECL_1(type, function,suffix, args) __attribute__ (attrib); \
^
/usr/include/math.h:63:31: note: expanded from macro '__MATHDECL_1'
extern type __MATH_PRECNAME(function,suffix) args __THROW
^
/usr/include/math.h:66:42: note: expanded from macro '__MATH_PRECNAME'
#define __MATH_PRECNAME(name,r) __CONCAT(name,r)
^
/usr/include/x86_64-linux-gnu/sys/cdefs.h:88:23: note: expanded from macro '__CONCAT'
#define __CONCAT(x,y) x ## y
I use clang-3.5. So I want to ask whether clang++ support constexpr math function. If so, what compiler flag I need to pass to clang?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-users/attachments/20140901/063c7346/attachment.html>
More information about the cfe-users
mailing list