public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug other/19088] New: volatile attr. doesn't work with pointers / wrong code
@ 2004-12-20 11:58 pluto at pld-linux dot org
2004-12-20 12:11 ` [Bug other/19088] " pluto at pld-linux dot org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: pluto at pld-linux dot org @ 2004-12-20 11:58 UTC (permalink / raw)
To: gcc-bugs
# testcase
typedef volatile unsigned mutex;
void lockMutex(mutex* m)
{
while (*m != 1);
*m = 0;
}
void unlockMutex(mutex* m)
{
*m = 0;
}
*** GCC 3.4.2-20040916 ***
00000000 <lockMutex>:
0: e5903000 ldr r3, [r0]
4: e3530001 cmp r3, #1 ; 0x1
8: 1afffffe bne 8 <lockMutex+0x8> <== should jump to 0x00.
c: e2433001 sub r3, r3, #1 ; 0x1
10: e5803000 str r3, [r0]
14: e1a0f00e mov pc, lr
00000018 <unlockMutex>:
18: e3a03000 mov r3, #0 ; 0x0
1c: e5803000 str r3, [r0]
20: e1a0f00e mov pc, lr
*** IAR C compiler ***
lockMutex:
0x00000180 E5901000 LDR R1, [R0, #+0]
0x00000184 E3510001 CMP R1, #0x1
0x00000188 1AFFFFFC BNE lockMutex ; 0x180 <=== this works fine.
0x0000018C E3A01000 MOV R1, #0x0
0x00000190 E5801000 STR R1, [R0, #+0]
0x00000194 E12FFF1E BX LR
unlockMutex:
0x00000198 E3A01000 MOV R1, #0x0
0x0000019C E5801000 STR R1, [R0, #+0]
0x000001A0 E12FFF1E BX LR
# arm-elf-gcc -v
Reading specs from c:/winarm/bin/../lib/gcc/arm-elf/3.4.2/specs
Configured with: ../../gcc-3.4.2-20040916-1/configure --enable-languages=c,c++
--enable-interwork --enable-multilib --with-gcc --with-gnu-ld --with-gnu-as
--with-stabs --disable-shared --disable-threads --disable-win32-registry
--disable-nls --target=arm-elf --with-newlib
--with-headers=/c/winarms/newlib-1.12.0/newlib/libc/include --prefix=c:/WinARM/
-v : (reconfigured) ../../gcc-3.4.2-20040916-1/configure
--enable-languages=c,c++ --enable-interwork --enable-multilib --with-gcc
--with-gnu-ld --with-gnu-as --with-stabs --disable-shared --disable-threads
--disable-win32-registry --disable-nls --target=arm-elf --with-newlib
--prefix=c:/WinARM/ -v
Thread model: single
gcc version 3.4.2 (mingw-special)
--
Summary: volatile attr. doesn't work with pointers / wrong code
Product: gcc
Version: 3.4.2
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: other
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: pluto at pld-linux dot org
CC: gcc-bugs at gcc dot gnu dot org
GCC host triplet: mingw
GCC target triplet: arm-elf
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19088
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug other/19088] volatile attr. doesn't work with pointers / wrong code
2004-12-20 11:58 [Bug other/19088] New: volatile attr. doesn't work with pointers / wrong code pluto at pld-linux dot org
@ 2004-12-20 12:11 ` pluto at pld-linux dot org
2004-12-20 12:52 ` pinskia at gcc dot gnu dot org
2004-12-20 13:03 ` rearnsha at gcc dot gnu dot org
2 siblings, 0 replies; 4+ messages in thread
From: pluto at pld-linux dot org @ 2004-12-20 12:11 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pluto at pld-linux dot org 2004-12-20 12:11 -------
oops, unlockMutex contains an error.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19088
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug other/19088] volatile attr. doesn't work with pointers / wrong code
2004-12-20 11:58 [Bug other/19088] New: volatile attr. doesn't work with pointers / wrong code pluto at pld-linux dot org
2004-12-20 12:11 ` [Bug other/19088] " pluto at pld-linux dot org
@ 2004-12-20 12:52 ` pinskia at gcc dot gnu dot org
2004-12-20 13:03 ` rearnsha at gcc dot gnu dot org
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-12-20 12:52 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-12-20 12:52 -------
This works for me on the mainline.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19088
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug other/19088] volatile attr. doesn't work with pointers / wrong code
2004-12-20 11:58 [Bug other/19088] New: volatile attr. doesn't work with pointers / wrong code pluto at pld-linux dot org
2004-12-20 12:11 ` [Bug other/19088] " pluto at pld-linux dot org
2004-12-20 12:52 ` pinskia at gcc dot gnu dot org
@ 2004-12-20 13:03 ` rearnsha at gcc dot gnu dot org
2 siblings, 0 replies; 4+ messages in thread
From: rearnsha at gcc dot gnu dot org @ 2004-12-20 13:03 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From rearnsha at gcc dot gnu dot org 2004-12-20 13:03 -------
Not a bug. You aren't showing the relocations that still need applying. You
need to add the -r flag to objdump for this.
Looking at the assembler output we see:
lockMutex:
@ args = 0, pretend = 0, frame = 0
@ frame_needed = 0, uses_anonymous_args = 0
@ link register save eliminated.
@ lr needed for prologue
.L2:
ldr r3, [r0, #0]
cmp r3, #1
bne .L2
sub r3, r3, #1
str r3, [r0, #0]
mov pc, lr
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19088
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2004-12-20 13:03 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-12-20 11:58 [Bug other/19088] New: volatile attr. doesn't work with pointers / wrong code pluto at pld-linux dot org
2004-12-20 12:11 ` [Bug other/19088] " pluto at pld-linux dot org
2004-12-20 12:52 ` pinskia at gcc dot gnu dot org
2004-12-20 13:03 ` rearnsha at gcc dot gnu dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).