Package: gcc
Version: 4:4.1.1-15
GCC miscompiles the following code :-
extern void extfunc(void);
extern unsigned extvar;
static void inner(char *a, unsigned b)
{
if (b)
extfunc();
else
extvar = (unsigned) a;
}
void outer(unsigned a, unsigned b)
{
char c;
c = a;
inner(&c, b);
}
/*
* with Debian Etch gcc
*
* gcc -O2 -c -o test.o test.c
*
* objdump -d test.o
*
* the initialisation of "c" that is needed
* for the assignment to "extvar" is done
* in the wrong leg of the if() !!
*
test.o: file format elf32-littlearm
Disassembly of section .text:
:
0: e52de004str lr, [sp, #-4]!
4: e351cmp r1, #0 ; 0x0
8: e24dd004sub sp, sp, #4 ; 0x4
c: 059f301cldreq r3, [pc, #28] ; 30 <.text+0x30>
10: 028d2003addeq r2, sp, #3 ; 0x3
14: 05832000streq r2, [r3]
18: 1a01bne 24
1c: e28dd004add sp, sp, #4 ; 0x4
20: e8bd8000ldmia sp!, {pc}
24: e5cd0003strbr0, [sp, #3]
28: ebfebl 0
2c: eafab 1c
30: andeq r0, r0, r0
*/
/*
Using built-in specs.
Target: arm-linux-gnu
Configured with: ../src/configure -v
--enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr
--enable-shared --with-system-zlib --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix --enable-nls
--program-suffix=-4.1 --enable-__cxa_atexit --enable-clocale=gnu
--enable-libstdcxx-debug --enable-mpfr --enable-checking=release
arm-linux-gnu
Thread model: posix
gcc version 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)
*/
/*
* same but with Debian Etch gcc-3.4
*
* this one is correct
*
test.o: file format elf32-littlearm
Disassembly of section .text:
:
0: e52de004str lr, [sp, #-4]!
4: e351cmp r1, #0 ; 0x0
8: 059f3020ldreq r3, [pc, #32] ; 30 <.text+0x30>
c: e24dd004sub sp, sp, #4 ; 0x4
10: e28d2004add r2, sp, #4 ; 0x4
14: e5620001strbr0, [r2, #-1]!
18: 05832000streq r2, [r3]
1c: 1a01bne 28
20: e28dd004add sp, sp, #4 ; 0x4
24: e8bd8000ldmia sp!, {pc}
28: ebfebl 0
2c: eafbb 20
30: andeq r0, r0, r0
*/
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]