Compiling GCC With a C++ Compiler (g++)
Gabriel Dos Reis
gdr@cs.tamu.edu
Wed Oct 13 14:53:00 GMT 2004
Andreas Schwab <schwab@suse.de> writes:
| Gabriel Dos Reis <gdr@cs.tamu.edu> writes:
|
| > If you can a strcture with const-qualified field, you can modify any
| > part, except that field. (I'm talking of C here).
|
| Yes, I'm also talking about C. And in C you can have const qualified
| lvalues that ultimatively denote modifiable objects.
But, in the tree_string case, it is not a modifiable object. See the
language I quoted in the other message.
| I can't see how it
| makes a difference that in this case it is declared as an array, since the
| underlying object is clearly writable.
It is not the fact that the field is declared an array, it is the fact
it is declared an array of *const* T.
Notice, Geoff made the following justification:
The 'const' is there to indicate that the string should not be changed
once the STRING_CST is created; STRING_CSTs may be shared.
but you can't have it both way: it can't be modifiable and
nonmodifiable. C says that if any member is const-qualified, the
whole stuff becomes non-modifiable. That put a several restriction on
how you can construct it. Either through brace-enclosed
initializer-list or fiddlinig with bytes before giving the tree_string
type.
Plus, this apply to the tree_node union too. I believe we have
reached a point where the change is clearly a bug.
-- Gaby
More information about the Gcc
mailing list