This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/14769] Block extern incorrectly resolved to file-scope internal linkage object
- From: "pinskia at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 29 Mar 2004 12:15:14 -0000
- Subject: [Bug c++/14769] Block extern incorrectly resolved to file-scope internal linkage object
- References: <20040329115900.14769.algrant@acm.org>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-03-29 12:15 -------
It seems to work correctly for me (for -fPIC and without I will only show with):
(without the extern int i;):
main:
pushl %ebp
movl %esp, %ebp
pushl %ebx
subl $20, %esp
call .LPR3
addl $_GLOBAL_OFFSET_TABLE_, %ebx
andl $-16, %esp
movl $0, %eax
subl %eax, %esp
movl 8(%ebp), %eax
movl %eax, 4(%esp)
leal .LC0@GOTOFF(%ebx), %eax
movl %eax, (%esp)
call printf@PLT
movl $0, %eax
movl -4(%ebp), %ebx
leave
ret
See how there is no reference to i, meaning that i is already "inlined".
Here are the asm for with the "extern int i;":
main:
pushl %ebp
movl %esp, %ebp
pushl %ebx
subl $20, %esp
call .LPR3
addl $_GLOBAL_OFFSET_TABLE_, %ebx
andl $-16, %esp
movl $0, %eax
subl %eax, %esp
movl i@GOT(%ebx), %eax
movl (%eax), %eax
movl %eax, 4(%esp)
leal .LC0@GOTOFF(%ebx), %eax
movl %eax, (%esp)
call printf@PLT
movl $0, %eax
movl -4(%ebp), %ebx
leave
ret
See how it goes through GOT,meaning it will pick up the extern one and not really always the local one.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14769