You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following program does not compile with clang r193986:
template
constexpr T PI = T(3.14);
template
constexpr T TAU = 2 * PI;
// A: Without this line using TAU below results in a compile error
//constexpr double HALF_PI = PI / 2;
int main(int argc, char**)
{
return TAU * argc;
}
This results in:
/LLVM/build/Release+Asserts/bin/clang -c -std=c++1y clang.cpp
clang.cpp:5:23: error: constexpr variable 'TAU' must be initialized by a constant expression
constexpr T TAU = 2 * PI;
~~~~^
clang.cpp:13:12: note: in instantiation of variable template specialization 'TAU' requested here
return TAU * argc;
^
1 error generated.
After uncommenting the line below "A", the code compiles successfully.
It seems that a constexpr variable template cannot be used in the definition of another constexpr variable template when it is not used in the definition of a non-template constexpr variable as well.
The text was updated successfully, but these errors were encountered:
Extended Description
The following program does not compile with clang r193986:
template
constexpr T PI = T(3.14);
template
constexpr T TAU = 2 * PI;
// A: Without this line using TAU below results in a compile error
//constexpr double HALF_PI = PI / 2;
int main(int argc, char**)
{
return TAU * argc;
}
This results in:
/LLVM/build/Release+Asserts/bin/clang -c -std=c++1y clang.cppclang.cpp:5:23: error: constexpr variable 'TAU' must be initialized by a constant expression
constexpr T TAU = 2 * PI;
~~~~^
clang.cpp:13:12: note: in instantiation of variable template specialization 'TAU' requested here
return TAU * argc;
^
1 error generated.
After uncommenting the line below "A", the code compiles successfully.
It seems that a constexpr variable template cannot be used in the definition of another constexpr variable template when it is not used in the definition of a non-template constexpr variable as well.
The text was updated successfully, but these errors were encountered: