Jakub Jelinek <jakub at gcc dot> changed:

           What    |Removed                     |Added
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot      |jakub at gcc dot

--- Comment #6 from Jakub Jelinek <jakub at gcc dot> ---
Created attachment 45706

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
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.

Reply via email to