Francois Gouget wrote:
I wrote a teeny test app to check this out and you're right. The static
is crucial. If it's not specified the string is copied to the stack so that the const essentially has no effect whatsoever (no compiler warning and no runtime error). With 'static const' we still don't get a compiler warning (tested with gcc version 3.3.3 (Debian 20040321)) but we get a runtime crash, i.e. the string is really const this time.
Now try the same prog, only compile it with g++ instead of gcc. Hmm - doesn't seem to have any important effect :-\