https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105297
--- Comment #10 from Patrick Palka <ppalka at gcc dot gnu.org> --- (In reply to Jakub Jelinek from comment #9) > (In reply to Patrick Palka from comment #7) > > (In reply to Jonathan Wakely from comment #6) > > > Patrick, I suggest we go with Jakub's suggestion in comment 4, but PTAL. > > > > LGTM, it seems to be the simplest workaround. I also tried replacing the > > NSDMI but that seems to prevent the ICE only for the reduced testcase in > > comment #3. > > Note, the original reduced testcase didn't have the " S" part in there, > i.e. used anonymous struct. Is that what matters for the NSDMI? Interestingly that doesn't seem to make a difference. What seems to matter is whether the constexpr function modifies the CONSTRUCTOR that it returns: constexpr auto foo() { struct S { int d; } t = {}; t.d = 0; // doesn't ICE if this line is commented out return t; } template<int> int bar() { constexpr auto t = foo(); return 0; }