This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Does the keyword volatile work?
- From: "Stephen P. Smith" <ischis2 at cox dot net>
- To: gcc at gcc dot gnu dot org
- Date: Mon, 12 May 2003 09:59:16 -0700
- Subject: Does the keyword volatile work?
In the code fragment below which was produced with a 3.3 version of the gcc compiler,
why isn't the variable p1 assigned to mailboxHandle immediately? I believe that the
keyword volatile should cause that to happen. BTW, the same behaviour has been observed
with the 2.95.2 compiler.
Command Line (-I -D switches removed for clarity):
i686-pc-elf-gcc -nostdinc -nostdinc++ -Wall -W -fno-exceptions -march=i586 \
-D__stdcall="__attribute__((__stdcall__))" -D__cdecl="__attribute__((__cdecl__))" \
-c -g -O3 -Wno-ctor-dtor-privacy -Wno-non-virtual-dtor -fno-rtti -fcheck-new \
-g -Wa,-a,-ad -o ipck.lst.temp ipck.cpp > ipck.lst
Code Fragment:
819:../../code/ipc/ipck.cpp **** DWORD CDECL someFunction(DWORD,DWORD p1,DWORD p2,DWORD p3,DWORD,DWORD)
820:../../code/ipc/ipck.cpp **** {
2664 .LM230:
2665 06d0 55 pushl %ebp
2666 06d1 89E5 movl %esp, %ebp
2667 06d3 57 pushl %edi
2668 06d4 56 pushl %esi
2669 06d5 53 pushl %ebx
2670 06d6 83EC0C subl $12, %esp
2672 .Ltext123:
2674 .LM231:
2675 .LBB297:
2676 .LBB298:
2677 .LBB299:
2678 06d9 A1000000 movl _ZN9Scheduler16itsRunningThreadE, %eax
2678 00
2680 .Ltext124:
821:../../code/ipc/ipck.cpp ****
822:../../code/ipc/ipck.cpp **** GenericHandleTYP var1 = (GenericHandleTYP)((volatile DWORD)p1);
823:../../code/ipc/ipck.cpp **** bool var2 = (bool)p2;
824:../../code/ipc/ipck.cpp **** timeoutSpecifier var3 = (timeoutSpecifier)p3;