Bug 81049

Summary: no warning for simple uninitialized variables
Product: gcc Reporter: Luc Van Oostenryck <luc.vanoostenryck>
Component: cAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED DUPLICATE    
Severity: normal    
Priority: P3    
Version: 7.1.0   
Target Milestone: ---   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed:

Description Luc Van Oostenryck 2017-06-10 09:14:45 UTC
gcc doesn't issue a warning for very simple cases of uninitialized variable. The options used are '-Wuninitialized -O2' or '-Wmaybe-uninitialized -O2'. It can be reproduced with gcc 5.4, 6.3 and gcc 7.1 (I didn't tried older versions).

One example of code to show this is:

	int g;
	int foo(void)
	{
		int r = 0;
		int u;

		if (g)
			r = u;
		return r;
	}
Comment 1 Marc Glisse 2017-06-10 09:44:06 UTC
Dup.

*** This bug has been marked as a duplicate of bug 18501 ***