Subject: Re: toolchain/22118: make won't compile with -Wcast-qual -Wstrict-prototypes and more
To: David Laight <david@l8s.co.uk>
From: Greg A. Woods <woods@weird.com>
List: tech-toolchain
Date: 07/16/2003 14:33:01
[ On Wednesday, July 16, 2003 at 11:53:22 (+0100), David Laight wrote: ]
> Subject: Re: toolchain/22118: make won't compile with -Wcast-qual -Wstrict-prototypes and more
>
> Surely the C way to remove 'const' is just a cast?

Such a cast would have to copy to guaranteed-to-be writable storage and
then hopefully arrange for it to be garbage-collected if it were to
successfully implement a true 'const_cast' that safely removed the
'const' qualifier.  The copying is necessary because of the possibility
that storage for a string constant might be shared with several
initializers and as such passing it to any code path which _might_ allow
for it to be written to would _potentially_ allow multiple string
constants to be modified.  In theory the compiler could work backwards
and untie identical string constants when one of them might end up being
cast to remove its "const" qualifier but ultimately I suspect that might
be functionally equivalent to just enabling -fwritable-strings in the
first place.

-- 
						Greg A. Woods

+1 416 218-0098                  VE3TCP            RoboHack <woods@robohack.ca>
Planix, Inc. <woods@planix.com>          Secrets of the Weird <woods@weird.com>