https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127260
Bug ID: 127260
Summary: ODR-use of reference NTTP bound to intermediate
constexpr reference variable fails
Product: gcc
Version: 13.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: svalorzen at gmail dot com
Target Milestone: ---
See on Godbolt: https://godbolt.org/z/sxqGqEGoM
I originally got it in 13.3, but on Godbolt it appears on every version. Clang
compiles it without issue.
Example code:
```
#include <tuple>
#include <cstdio>
struct E { int i; };
static constexpr std::tuple<E, E> s{E{1}, E{2}};
template <const auto& Elem>
struct V { static constexpr int tag = Elem.i; };
template <std::size_t I>
struct Pick {
static constexpr const E& z = std::get<I>(s);
static constexpr int tag = V<z>::tag;
};
int main() {
// Works fine if passed by value: std::printf("%d\n", Pick<0>::tag);
// Fails when address is taken:
std::printf("%p\n", (const void*) &Pick<0>::tag);
}
```