GCC 4.0.0 and later optimize out struct assignments inappropriately when the struct is used as an input to an asm(). For example, in:
int foo(int a, int b) { struct {int a,b} args; args.a = a; args.b = b; asm("..." : "" : "S" (&args)); } the args.a and args.b assignments are optimized out (with -O3 at least) despite the structure being specified as an input to the asm(). See attached files. -- Summary: Improper removal of struct field assignments by optimizer Product: gcc Version: 4.0.1 Status: UNCONFIRMED Severity: normal Priority: P2 Component: regression AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: gcczilla at achurch dot org CC: gcc-bugs at gcc dot gnu dot org GCC build triplet: i686-pc-linux-gnu GCC host triplet: i686-pc-linux-gnu GCC target triplet: i686-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23328