Bug 94144

Summary: gcc: strange "is used uninitialized" reports
Product: [openSUSE] SUSE LINUX 10.0 Reporter: Stanislav Brabec <sbrabec>
Component: BasesystemAssignee: Michael Matz <matz>
Status: RESOLVED WONTFIX QA Contact: E-mail List <qa-bugs>
Severity: Minor    
Priority: P5 - None    
Version: Stable Snapshot 2   
Target Milestone: ---   
Hardware: Other   
OS: All   
Whiteboard:
Found By: Other Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Description Stanislav Brabec 2005-06-27 12:26:43 UTC
Attached code reports following warning:

unused.c: In function ‘main’:
unused.c:14: warning: ‘testvar.unusedval’ is used uninitialized in this function

Uncommenting "forget (testvar)" on line 15, this warning disappears, which is
even more strange.

The warning is invalid (should be "may be used uninitialized"), because gcc has
no knowledge about forget().

Related: http://bugzilla.gnome.org/show_bug.cgi?id=308923

gcc -c -O2 -Wall unused.c
------
struct testme {
    int testval;
    int unusedval;
};

extern void forget (struct testme forgotten);

int
main () {
    struct testme testarray[1];
    {
	struct testme testvar;
	testvar.testval = 0;
	testarray[0] = testvar;
/*	forget (testvar);*/
    }
    forget (testarray[0]);
    return 0;
}
Comment 1 Michael Matz 2005-06-27 13:25:50 UTC
Entered as http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22197 . 
Comment 2 Andreas Jaeger 2007-05-03 07:54:18 UTC
Tracked upstream and will end in a future product...

Marking as wontfix for 10.0