Bug 81049 - no warning for simple uninitialized variables
Summary: no warning for simple uninitialized variables
Status: RESOLVED DUPLICATE of bug 18501
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 7.1.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
Depends on:
Reported: 2017-06-10 09:14 UTC by Luc Van Oostenryck
Modified: 2017-06-10 09:44 UTC (History)
0 users

See Also:
Known to work:
Known to fail:
Last reconfirmed:


Note You need to log in before you can comment on or make changes to this bug.
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

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