egcs1019: Problem with C++ code gen on args passed const char when declared void *
Mark Mitchell
mark@markmitchell.com
Thu Oct 29 20:55:00 GMT 1998
>>>>> "Kenneth" == Kenneth & Susan <kenbo@ne.mediaone.net> writes:
Kenneth> Hello,
Kenneth> In C++ code, the following used to emit a warning, but
Kenneth> now is an error (as of 1019 and 1026 snapshots, 0921
Kenneth> works fine). Is this supposed to be the new behavior?
Kenneth> Function foo is declared foo( void * bar), in usage, is
Kenneth> used with the syntax foo("ch") and get:
Kenneth> passing `const char *' as argument 1 of `foo(void *)'
Kenneth> discards qualifiers
Kenneth> which used to be warning, but now breaks compilation.
This is an interesting question. A string literal is of type `const
char[n]', but can be converted to a `char*' (as opposed to a `const
char*') when "there is an explicit appropriate pointer target type".
I don't actually understand this sentence. In any case, this
conversion is deprecated, and should be avoided. Does anyone fully
understand this sentence I quoted from the standard, or have a sense
as to the intent of the committee?
--
Mark Mitchell mark@markmitchell.com
Mark Mitchell Consulting http://www.markmitchell.com
More information about the Gcc-bugs
mailing list