Strange(?) g++ behavior with references (egcs1.0.1).
Sergei Organov
osv@javad.ru
Tue Feb 17 07:57:00 GMT 1998
Hello;
g++ for PowerPC target produces correct but very strange(?) results for
the code below. Could somebody comment on that, please.
int volatile &
r1 = *(int volatile *)10; // g++ puts 'r1' to '.sdata'.
// why not into '.sdata2' ?
int volatile &
r2 = *(int *)20; // generates run-time(!) initialization for 'r2'.
int volatile *const p1 = (int volatile *)10; // Ok, '.sdata2'
int volatile *const p2 = (int *)20; // Ok, '.sdata2'
Here is result of compilation:
.file "volref.cc"
# rs6000/powerpc options: --with-cpu=505 -msdata=eabi -G 8
# GNU C++ version egcs-2.90.23 980102 (egcs-1.0.1 release) (ppc-rtems)
compiled
# options passed: -mcall-sysv -meabi -msdata=eabi
# options enabled: -fpeephole -ffunction-cse -fkeep-static-consts
# -fpcc-struct-return -fexceptions -fsjlj-exceptions -fcommon
# -fverbose-asm -fgnu-linker -fargument-alias -mpowerpc -mnew-mnemonics
# -meabi -mcall-sysv -msdata=eabi
gcc2_compiled.:
.globl r1
.section ".sdata","aw"
.align 2
.type r1,@object
.size r1,4
r1:
.long 10
.globl r2
.align 2
r2:
.space 4
.size r2,4
.section ".text"
.align 2
.globl _GLOBAL_.I.r1
.type _GLOBAL_.I.r1,@function
_GLOBAL_.I.r1:
stwu 1,-16(1)
stw 31,12(1)
mr 31,1
li 0,20
stw 0,r2@sda21(0)
b .L2
b .L1
.L2:
.L1:
lwz 11,0(1)
lwz 31,-4(11)
mr 1,11
blr
.Lfe1:
.size _GLOBAL_.I.r1,.Lfe1-_GLOBAL_.I.r1
.section .ctors,"aw"
.long _GLOBAL_.I.r1
.section ".sdata2","a"
.align 2
.type p1,@object
.size p1,4
p1:
.long 10
.align 2
.type p2,@object
.size p2,4
p2:
.long 20
.ident "GCC: (GNU) egcs-2.90.23 980102 (egcs-1.0.1 release)"
More information about the Gcc-bugs
mailing list