https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100468
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
I meant something like
struct S { constexpr S () : s (0), t (0), u(0) {} constexpr S (int x, int y,
int z) : s (x), t (y), u (z) {} int s, t, u; };
constexpr S bar () { return S (0, 1, 2); }
bool
foo (void)
{
constexpr static const S&& a = bar ();
constexpr static const S&& b = bar ();
return &a == &b;
}
int
main ()
{
if (foo ())
__builtin_abort ();
}
but haven't tried your patch to see if it triggers.
I certainly see
static const struct S & a = (const struct S &) &_ZGRZ3foovE1a_;
static struct S _ZGRZ3foovE1a_ = {.s=0, .t=1, .u=2};
static const struct S & b = (const struct S &) &_ZGRZ3foovE1b_;
static struct S _ZGRZ3foovE1b_ = {.s=0, .t=1, .u=2};
in the gimple dump and I believe the _ZGRZ3foovE1*_ vars are DECL_ARTIFICIAL.