Bug 69578 - -Wuninitialized not issuing warning.
Summary: -Wuninitialized not issuing warning.
Status: RESOLVED DUPLICATE of bug 18501
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 5.2.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
Depends on:
Blocks: Wuninitialized
  Show dependency treegraph
 
Reported: 2016-01-31 16:59 UTC by lvenkatakumarchakka
Modified: 2018-09-10 20:49 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 5.3.1, 6.3.0, 7.0
Last reconfirmed: 2017-03-29 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description lvenkatakumarchakka 2016-01-31 16:59:42 UTC
int main()
{
	int i, j;
	for( j=0; j<10; j++ )
	{
		printf( "%d\n", i );
		for( i=0; i<10;i++ );
	}
	return 0;
}


compiling above code with -Wuninitialized is supposed to issue warning which is not happening.
Comment 1 Richard Biener 2016-02-01 09:27:52 UTC
It does if you enable -O1 (but not with -O0 or -O2+)
Comment 2 Martin Sebor 2017-03-29 15:23:21 UTC
Confirmed with the top of trunk (7.0).
Comment 3 Marc Glisse 2017-03-29 15:32:24 UTC
It is a dup of all the uninit PRs caused by CCP turning PHI<undef, X> into X (X=10 here).
Comment 4 Peter Selinger 2018-09-10 00:54:59 UTC
I ran into the same bug with this code:

double weight() {
  double sum;
  int i;

  for (i=0; i<10; i++) {
    sum++;
  }
  return sum;
}

With -Wuninitialized or -Wmaybe-uninitialized, no warning is generated with -O0. The warning is generated with -O1, -O2, -O3. Other compilers (such as clang) generate the warning correctly.

Confirmed with gcc 8.2.0.
Comment 5 Manuel López-Ibáñez 2018-09-10 20:49:28 UTC
Original report is PR18501.

Comment #4 is PR54554.

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