Bug 118911

Summary: gcc warning without reason
Product: [openSUSE] SUSE LINUX 10.0 Reporter: Jan Engelhardt <jengelh>
Component: DevelopmentAssignee: Michael Matz <matz>
Status: VERIFIED FIXED QA Contact: E-mail List <qa-bugs>
Severity: Normal    
Priority: P5 - None CC: meissner
Version: RC 1   
Target Milestone: ---   
Hardware: x86   
OS: Linux   
Whiteboard:
Found By: Beta-Customer Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Attachments: testcase

Description Jan Engelhardt 2005-09-26 20:31:06 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
Comment 1 Jan Engelhardt 2005-09-26 20:31:37 UTC
Created attachment 50861 [details]
testcase

gcc -c mx.c

No linking needed.
Comment 2 Marcus Meissner 2005-09-27 07:54:41 UTC
well, the whole struct is passed marked as const, so probably the field 
are considered const too. 
Comment 3 Michael Matz 2005-10-04 14:59:31 UTC
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.