Take the following code: #include <stdarg.h> int foo (int a, ...) { va_list ap; va_list ap1; va_list ap2; va_list ap3; va_list ap4;
va_start (ap, a); int b; ap1 = ap; ap2 = ap1; do { ap1 = ap2; b = va_arg (ap1, int); ap2 = ap1; } while (b > 10); return a + b; } int main () { if (foo (1, 2, 3) != 3) abort (); return 0; } --- With -O1, we get an abort as the argruments at not saved to the stack at all. This is reduced/changed from 20000519-1.c which was exposed by RTH's patch: * c-common.c (handle_mode_attribute): When not modifying in place, create subtypes for enumerations. (sync_resolve_return): Use TYPE_MAIN_VARIANT. * gimplify.c (create_tmp_from_val): Likewise. -- Summary: [4.1 Regression] tree-stdarg.c causes wrong code, not tracking va_list variable correctly Product: gcc Version: 4.1.0 Status: UNCONFIRMED Keywords: wrong-code Severity: critical Priority: P2 Component: tree-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: pinskia at gcc dot gnu dot org CC: gcc-bugs at gcc dot gnu dot org GCC target triplet: powerpc-darwin,powerpc-aix http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24126