This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFC] warning: initialization discards qualifiers from pointertarget type


> warning: initialization discards qualifiers from pointer target type
>
> This warning can not be disabled using -Wno-cast-qual
> (or any other warning flags). Is it intentional ?
> Otherwise I'll prepare patch.
>
> const char *a( void )
> {
>        return "abc";
> }
>
> int main( void )
> {
>       char *s = a();
>        return 0;
> }

Actually I'd like to think this is enforced as an "illegal" assignment.

(as it seem wrong to "discard pointer qualifiers" unless the assignment
 actually "copies" the literal string, which I don't believe it does;
 as any attempt to write to a const string literal should not be valid?)



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]