[Bug c/63880] GCC overoptimization on local arrays of size 1
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63880 --- Comment #4 from Richard Biener rguenth at gcc dot gnu.org --- Indeed this is a case we don't handle as QOI special-case (we accept other cases of strictly undefined code though). In this case it is recommended to just do arglist *p = malloc (sizeof (arglist) + sizeof (char *) * 1000); and as Andrew said not wrap arglist inside another struct which appends a member.
[Bug c/63880] GCC overoptimization on local arrays of size 1
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63880 --- Comment #1 from Kai Petzke petzke at teltarif dot de --- Created attachment 33980 -- https://gcc.gnu.org/bugzilla/attachment.cgi?id=33980action=edit A file with small modifications from overoptimized.c, that compiles correctly.
[Bug c/63880] GCC overoptimization on local arrays of size 1
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63880 Andrew Pinski pinskia at gcc dot gnu.org changed: What|Removed |Added Status|UNCONFIRMED |RESOLVED Resolution|--- |INVALID --- Comment #2 from Andrew Pinski pinskia at gcc dot gnu.org --- In general, C code may rely on the fact Maybe but this is undefined code in C.
[Bug c/63880] GCC overoptimization on local arrays of size 1
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63880 --- Comment #3 from Andrew Pinski pinskia at gcc dot gnu.org --- if you allocated an arglist via malloc (or alloca) and not have a struct which contained arglist, it would be valid (well GCC would do the correct thing as we define it as being valid).