Closed brevzin closed 4 weeks ago
@llvm/issue-subscribers-clang-frontend
I believe this is: https://github.com/llvm/llvm-project/issues/56695
If I modify the code to use a templated struct I receive the same diagnostic: https://godbolt.org/z/n375vaqEM
template <int const*>
constexpr int f() {
return 0;
}
template <int const&>
constexpr int f2() {
return 0;
}
template <int const*> struct W{};
struct X { int i; };
constexpr X x = X{.i=1};
constexpr int xs = f<&x.i>();
W<&x.i> w;
struct Z { int i; };
constexpr Z z{};
template<const int&> struct Y { };
constexpr int ys = f2<x.i>();
Y<x.i> y;
@llvm/issue-subscribers-c-2b
@shafik Yep, same issue!
Should be C++20 tho (not 2b)
@llvm/issue-subscribers-c-20
Fixed in 18
Short example:
Clang rejects (every version I've tried), saying:
But
&x.i
should meet all the requirements here - it is a pointer toint const
and the object in question does have static storage duration (so it should be a permitted result of a constant expression).