https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63233

--- Comment #5 from leis at in dot tum.de ---
Thanks. I did notice that I get warning with optimization but not without,
which is strange indeed.

However, obviously my real problem is more complicated, and I'm trying to
understand if I violate the standard. If I pick apart the offending
line (foo.a[1] = 99;):

int* p1 = foo.a;  //1
int* p2 = p1 + 1; //2
*p2 = 99;         //3

Which of these lines causes the undefined behavior? Why should pointer p2 be
invalid?

Fundamentally, what I'm really trying to do, is to have two arrays (of
different types) in a fixed-sized struct. One array grows from the front, and
one from the end. Dynamically I make sure that they do not overlap, but the
sizes of the two arrays are not known statically. Is it really violating the
standard?

Reply via email to