[Bug c/37755] Mistaken Segmentation fault
--- Comment #4 from rguenth at gcc dot gnu dot org 2008-10-07 07:37 --- As Joseph said. Invalid for -std=c89, worksforme for -std=c99. No changes needed for -std=c1x. -- rguenth at gcc dot gnu dot org changed: What|Removed |Added Status|NEW |RESOLVED Resolution||INVALID http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37755
[Bug c/37755] Mistaken Segmentation fault
--- Comment #3 from joseph at codesourcery dot com 2008-10-06 21:39 --- Subject: Re: New: Mistaken Segmentation fault On Mon, 6 Oct 2008, charpour at gnet dot gr wrote: > printf("%s\n", make_person().name); make_person().name is a non-lvalue array, so it only decays to a pointer for C99, not for C90. If you use -std=c99/-std=gnu99 then the program works. The program does not, however, have defined behavior for C99, only for C1x. In C99 the lifetime of the array ends at the next sequence point, before the call to printf. In C1x it instead ends at the end of the evaluation of the containing full expression, which is the call to printf. I do not believe any changes to GCC are needed to implement this particular C1x requirement, since GCC discards information about variables lifetimes smaller than a function for gimplification and tree optimizations that may change those lifetimes, so it will in practice treat the lifetime as being anywhere it cannot show the temporary not to be live. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37755
[Bug c/37755] Mistaken Segmentation fault
--- Comment #2 from pinskia at gcc dot gnu dot org 2008-10-06 21:25 --- Confirmed. -- pinskia at gcc dot gnu dot org changed: What|Removed |Added Status|UNCONFIRMED |NEW Ever Confirmed|0 |1 Last reconfirmed|-00-00 00:00:00 |2008-10-06 21:25:33 date|| http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37755
[Bug c/37755] Mistaken Segmentation fault
--- Comment #1 from pinskia at gcc dot gnu dot org 2008-10-06 21:25 --- I don't get a seg fault on ppc but I do on x86. It works correctly for the C++ front-end where the array decays into a pointer. The warning is also bogus but it shows what the issue is really. -- pinskia at gcc dot gnu dot org changed: What|Removed |Added Keywords||diagnostic, wrong-code http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37755