This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Const bug
- To: gcc-bugs at gcc dot gnu dot org
- Subject: Const bug
- From: Andrew Apted <ajapted at netspace dot net dot au>
- Date: Thu, 5 Jul 2001 03:59:44 +1000
- Reply-To: Andrew Apted <ajapted at netspace dot net dot au>
Hi,
I think I've found a bug in G++ (I'm not 100% sure it's a bug
but it does seem pretty counter-intuitive), where variables marked
const are treated differently to non-const variables, almost like they
were considered as static. With optimisation on, the symbols don't
appear in the object file at all.
The file `about.cpp' looks like this:
const int foo = 3;
int bar = 7;
Compiled like this:
g++ -g -Wall -DGLBSP_GUI -DUNIX -DINLINE_G=inline -I/usr/local/lib
-c -o about.o about.cpp
(and with -O for optimisation case). No errors or warnings.
The output of `nm about.o' is:
00000000 t Letext
00000000 ? __FRAME_BEGIN__
00000000 D bar
00000000 r foo
Or with optimisation:
00000000 t Letext
00000000 ? __FRAME_BEGIN__
00000000 D bar
You can see how `foo' is missing. Bug ?
I'm running Linux (Debian Potato) system on i386, gcc version 2.95.2,
ld version 2.9.5 (with BFD 2.9.5.0.37), Glibc 2.1,
Cheers,
__
\/ Andrew Apted <ajapted@users.sourceforge.net>