g++ otimizes out const globals
Mike Stump
mrs@wrs.com
Mon Mar 15 19:27:00 GMT 1999
> Date: Mon, 15 Mar 1999 16:52:37 -0800
> From: John Milford <jwm@CSUA.Berkeley.EDU>
> In the case of a single variable as seen below, the compiler
> would do constant folding within the scope of the file, but the
> compiler can't fold table lookups, so this is a problem when it
> happens to arrays.
Again, I don't see any problems. You have failed to give me a
testcase. I create testcases based upon your words, and I don't see
any problems.
If you wish to report a problem, please include a testcase of the
problem you want to report.
> It is not possible to link if a function uses this variable
> from a different file.
Not a bug. I think you think that const int foo = 5; is external, it
is not. If you want external, the way to spell it is `extern'.
> There is no symbol, therefore the link will fail with an unresolved
> symbol error. The symbol should be global, and therfore visible
> during linking.
? No.
More information about the Gcc-bugs
mailing list