[RFC] warning: initialization discards qualifiers from pointer target type
Devang Patel
dpatel@apple.com
Tue Apr 19 19:39:00 GMT 2005
On Apr 19, 2005, at 11:51 AM, James E Wilson wrote:
> Devang Patel wrote:
>> On Apr 18, 2005, at 6:29 PM, James E Wilson wrote:
>>> I notice that these are pedwarns,
>> In that case, we can enable it only when -pedantic is used (like
>> many pedwarns) ?
>
> Consider this small modification to your testcase.
>
> const char *a( void )
> {
> return "abc";
> }
>
> int main( void )
> {
> char *s = a();
> s[0] = 'c';
> return 0;
> }
>
> This will core dump when run on any system that write-protects read-
> only data. The only warning that you will get from gcc is the one
> that you are asking us to disable. This is the reason for the
> warning, as it is necessary to detect unsafe code like this.
This makes sense. On the other side, we (Apple) still support -
fwritable-stings ;)
> I don't believe this warning should depend on -pedantic, as it is
> doing something useful. I think a special -Wno- option makes more
> sense.
OK.
> I was going to ask why you need this change, but you already
> answered that question. If I had a customer getting 55k+ warnings,
> I'd want to add an option for them also.
I'll try to convince customer one more time. If it did not work then
I'll prepare patch to control this warning using -Wno-discard-qual.
Thanks,
> --
> Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com
-
Devang
More information about the Gcc
mailing list