https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64160
Bug ID: 64160 Summary: msp430 code generation error adding 32-bit integers Product: gcc Version: 5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: pab at pabigot dot com This program: struct adjustment { unsigned long duration; }; unsigned long read_clock (); int dosomething (struct adjustment * ap, unsigned long v); int doit (struct adjustment * ap) { return dosomething(ap, read_clock() + ap->duration); } when compiled with msp430-elf-gcc -Os -S produces: ; start of prologue PUSHM.W #1, R10 ; end of prologue MOV.W R12, R10 CALL #read_clock MOV.W @R10, R13 <<-- error half of return value clobbered ADD R12, R13 ; cy MOV.W 2(R10), R14 ADDC R13, R14 <<-- R13 is not what it should be MOV.W R10, R12 CALL #dosomething which produces the wrong answer because the upper word of the result from read_clock was overwritten by the read from memory.