Bugzilla – Bug 118911
gcc warning without reason
Last modified: 2006-07-15 09:30:03 UTC
Compile attached file -- no special flags needed, gcc mx.c, and I get the error mx.c: In function ■fail■: mx.c:10: warning: assignment discards qualifiers from pointer target type It does not happen with the other two functions which are equivalent. 22:30 shanghai:~ > rpm -q gcc gcc-4.0.2_20050901-3
Created attachment 50861 [details] testcase gcc -c mx.c No linking needed.
well, the whole struct is passed marked as const, so probably the field are considered const too.
This warning indeed is invalid (Marcus: the field itself is indeed considered const, but that doesn't mean that the pointed-to memory is readonly, i.e. the type of c->var in this context is "char * const var", but not "const char *". ) This is meanwhile fixed in 4.1 which doesn't give the wrong warning anymore. There are no plans to backport this specifically to 4.0, so I'll close this as FIXED.