Non-type template arguments in clang

Viewed 20

When I try to compile the following code:

struct S { int a; };
template <const int*> struct T {};
constexpr S kS{.a = 42};
constexpr T<&kS.a> kT;
int main() { return 0; }

it works on gcc, but fails on clang:

<source>:4:13: error: non-type template argument refers to subobject '&kS.a'
constexpr T<&kS.a> kT;

I wasn't able to find anything about this error. Does anybody knows what this is about, is it a missing feature, or a quirk of the c++ standard, or perhaps something yet else? Are there any workarounds other than copying the value? Any help would be appreciated.

0 Answers
Related