This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Const bug


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>
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]