static variable placed in text section
Wade Jensen
Wade_Jensen@inter-tel.com
Fri Oct 12 15:33:00 GMT 2001
Hello,
I do not know if this is a new bug or not, but I saw some strange behavior with
a cvs version of gcc:
Configured with: ../../source/gcc/configure --target=m68k-elf
--prefix=/crossgnu/m68k-elf --program-prefix=m68k-elf- --with-gnu-as
--with-gnu-ld --with-newlib --enable-languages=c,c++ --verbose
Thread model: single
gcc version 3.1 20011008 (experimental)
The following code:
#################### BEGIN ############################
class tempA
{
public:
int tempf()
{
static int tempa = 0;
return tempa++;
}
} A;
int tempg()
{
static int tempb = 0;
A.tempf();
return tempb++;
}
#################### END ############################
Produces the following output for the -m5200:
#################### BEGIN ############################
10016930 <_Z5tempgv>:
class tempA
{
public:
int tempf()
{
static int tempa = 0;
10016930: 7001 moveq #1,%d0
10016932: d1b9 1007 7af8 addl %d0,
return tempa++;
}
} A;
int tempg()
{
static int tempb = 0;
A.tempf();
return tempb++;
10016938: 2039 1030 1340 movel ,%d0
1001693e: 7201 moveq #1,%d1
10016940: d3b9 1030 1340 addl %d1,
}
10016946: 4e75 rts
#################### END ############################
Notice that it incorrectly places the static variable tempa at 0x10077af8, which
is in my text section. It correctly places the static variable tempb at
0x10301340, which is in my data section.
Thanks,
Wade
Inter-Tel -- Your Connection to the Future
http://www.inter-tel.com
More information about the Gcc-bugs
mailing list