https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100976
--- Comment #3 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
(In reply to Jason Merrill from comment #2)
> Or rather,
>
> int main()
> {
> constexpr const int &r = 42;
> static_assert(r == 42); // { dg-bogus "" }
> }
>
> [expr.const]/4.7 says that "a temporary object of non-volatile
> const-qualified literal type whose lifetime is extended to that
> of a variable that is usable in constant expressions" is usable in a
> constant expression.
This was actually CWG 2126 which we don't seem to fully implement:
struct A { int n; };
const A &a = {1}; // const temporary
A &b = (A &)(const A &)A{1}; // const temporary
A &&c = (A &&)(const A &)A{1}; // const temporary
static_assert(a.n == 1, "");
static_assert(b.n == 1, "");
static_assert(c.n == 1, "");