Const bug

Nathan Sidwell nathan@acm.org
Thu Jul 5 02:05:00 GMT 2001


Andrew Apted wrote:

> The file `about.cpp' looks like this:
> 
>    const int foo = 3;
>    int bar = 7;
Not a bug. constant objects are not externally visible, unlesss
explicitly
`extern'.

> The output of `nm about.o' is:
> 
>    00000000 t Letext
>    00000000 ? __FRAME_BEGIN__
>    00000000 D bar
>    00000000 r foo
You'll notice foo is `r', a local read only object

> Or with optimisation:
> 
>    00000000 t Letext
>    00000000 ? __FRAME_BEGIN__
>    00000000 D bar
> 
> You can see how `foo' is missing.  Bug ?
optimization :-)

nathan

-- 
Dr Nathan Sidwell :: Computer Science Department :: Bristol University
Never hand someone a gun unless you are sure where they will point it
nathan@acm.org  http://www.cs.bris.ac.uk/~nathan/  nathan@cs.bris.ac.uk



More information about the Gcc-bugs mailing list