The attached code produces wrong-code on gcc-4.1.1 and gcc-4.1.2 on ARM. These codes are snippet from linux kernel, and this was found when linux v2.6.19 was built with gcc-4.1.1 with CONFIG_PRINK_TIME=y is set for ARM.
$ arm-linux-gcc -O2 -c div64.S $ arm-linux-gcc -O2 -save-temps dodiv.c div64.o -o dodiv actual result: $ ./dodiv tbuf: <4>[ 52.305419] expected result: tbuf: <4>[ 0.305419] when compiled with -fno-tree-ter, the result was OK. The problem comes from bad argument passing to sprintf(), looking from dodiv.s: ... mov r2, r5 <<<<<< (1) mov ip, ip, lsr #6 mov r3, r5 <<<<<< (2) ldr r1, .L10+8 mov r0, r4 str ip, [sp, #0] bl sprintf Where (1) is loglev_char argument and (2) is (unsigned long)t argument in sprintf() in dodiv.c. Apparently, the loglev_char is also assigned to the first %5lu part of sprintf, which is the cause. -- Summary: bad argument passing on ARM Product: gcc Version: 4.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: rtl-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: kaminaga at sm dot sony dot co dot jp GCC target triplet: arm-*-linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31143