https://bugs.llvm.org/show_bug.cgi?id=52044
Bug ID: 52044
Summary: non-type template argument constexpr when passed by
reference
Product: clang
Version: 12.0
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: C++
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected],
[email protected], [email protected],
[email protected]
Hi,
the following code does not work with clang++ 12 and trunk version
***
#include<cstring>
#include<array>
template<size_t N> struct S {
static constexpr size_t n = N;
};
template<size_t N>
void foo(const S<N> &s) {
std::array<char, s.n> arr;
}
int main() {
foo(S<3>{});
}
***
It fails with error
error: non-type template argument is not a constant expression
std::array<char, s.n> arr;
The gcc and msvc compile this snippet without issues
(https://godbolt.org/z/ffGna7xE8)
Interestingly, if I remove the reference in foo argument type - it works.
Surprisingly the clang 12 from the LLVM windows bundle also works.
Regards,
Alex
--
You are receiving this mail because:
You are on the CC list for the bug._______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs