https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89336
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED Assignee|unassigned at gcc dot gnu.org |jakub at gcc dot gnu.org --- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Created attachment 45706 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=45706&action=edit gcc9-pr89336.patch Untested fix. Pointing a pointer into a middle of vector that might be reallocated or where new elements might be added before the one to which we store (and that addition memmoves all the rest upwards) is dangerous. This patch should fix that, except that it doesn't fix union handling. I think e.g. constexpr int foo () { union U { int a; long b; }; union V { union U u; short v; }; V w {}; w.u.a = w.v = w.u.b = 5L; return w.u.a; } static_assert (foo () == 5, ""); ICEs with it (previously it would fail). Is the testcase valid C++? clang++ rejects it. The question is when exactly becomes a union member active on the assignment, if only after evaluating the rhs, or it first becomes active member, then rhs is evaluated.