Hello, Following code (written just for fun) leads to:
Program received signal SIGSEGV, Segmentation fault. main () at main-general.cpp:95 95 printf("%d\n", x_reg); BTW, there is warning when using ecx, eax, edx. should there be any warning for esp? gcc svn://gcc.gnu.org/svn/gcc/branches/gcc-4_4-branch Revision: 150651 x86 / cpu info vendor_id : GenuineIntel cpu family : 6 model : 15 Compile flags: -g3 -O2 --- volatile register int x_reg asm ("esp"); int ff_() { x_reg = rand(); return x_reg; } int main() { x_reg = ff_(); x_reg++; printf("%d\n", x_reg); return 1; } Dump of assembler code for function _Z3ff_v: 0x080489c0 <_Z3ff_v+0>: push %ebp 0x080489c1 <_Z3ff_v+1>: mov %esp,%ebp 0x080489c3 <_Z3ff_v+3>: sub $0x8,%esp 0x080489c6 <_Z3ff_v+6>: call 0x80487a4 <r...@plt> 0x080489cb <_Z3ff_v+11>: mov %eax,%esp 0x080489cd <_Z3ff_v+13>: mov %esp,%eax 0x080489cf <_Z3ff_v+15>: leave 0x080489d0 <_Z3ff_v+16>: ret (gdb) disassemble main Dump of assembler code for function main: 0x080489e0 <main+0>: push %ebp 0x080489e1 <main+1>: mov %esp,%ebp 0x080489e3 <main+3>: and $0xfffffff0,%esp 0x080489e6 <main+6>: sub $0x10,%esp 0x080489e9 <main+9>: call 0x80489c0 <_Z3ff_v> 0x080489ee <main+14>: lea 0x1(%eax),%esp 0x080489f1 <main+17>: mov %esp,0x4(%esp) 0x080489f5 <main+21>: movl $0x8048bd0,(%esp) 0x080489fc <main+28>: call 0x8048774 <pri...@plt> << 0x08048a01 <main+33>: mov $0x1,%eax 0x08048a06 <main+38>: leave 0x08048a07 <main+39>: ret Sergey -- Summary: SIGSEGV with register asm esp Product: gcc Version: 4.4.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: sergey dot senozhatsky at mail dot by http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41036