Bug 82203 - [5/6/7/8 regression] missing -Wmaybe-uninitialized warning with tree-vrp
Summary: [5/6/7/8 regression] missing -Wmaybe-uninitialized warning with tree-vrp
Status: RESOLVED DUPLICATE of bug 18501
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 8.0
: P3 normal
Target Milestone: 5.5
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
Depends on:
Blocks: Wuninitialized
  Show dependency treegraph
 
Reported: 2017-09-13 11:46 UTC by Arnd Bergmann
Modified: 2017-09-14 16:10 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work: 4.8.5
Known to fail: 8.0
Last reconfirmed: 2017-09-13 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Arnd Bergmann 2017-09-13 11:46:11 UTC
I've looked at warnings I get in the Linux kernel with older compilers but not with more modern versions. Unsurprisingly, most are false positives, but I found three files that show a particular pattern that should be warned about:

$ gcc-8.0.0 -Wall -c test.c -O2 # no warning
$ gcc-8.0.0 -Wall -c test.c -O2 -fno-tree-vrp # warning
test.c:12:9: warning: 'err' may be used uninitialized in this function [-Wmaybe-uninitialized]
$ gcc-4.8 -Wall -c test2.c -O2 # warning
test.c:12:2: warning: ‘err’ may be used uninitialized in this function [-Wmaybe-uninitialized]

The original warnings all show up with gcc-4.6 and earlier, but not with gcc-4.7+. The reduced test case also produces a warning with 4.7 and 4.8 but not with 4.9 through 8.0 unless -ftree-vrp is disabled:

8<---
int f(void);
int mlx5_fpga_mem_read_i2c(int count)
{
	int i, err;

	for (i = 0; i < count; i++) {
		err = f();
		if (err)
			break;
	}

	return err;
}
----->8

There are a lot of similar reports that are all marked duplicates of pr18501, but none of them have the particular loop/break pattern that I found in the three kernel files, so I'm opening another one to be sure.

If the underlying problem is the same, please mark this one as duplicate as well.
Comment 1 Richard Biener 2017-09-13 13:54:00 UTC
We're just better in optimization as we figure that err is either uninitialized, zero or the f return value.  And we now optimistically merge uninitialized with zero.
Comment 2 Jakub Jelinek 2017-09-14 16:10:54 UTC
Dup.

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