https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82203

            Bug ID: 82203
           Summary: [4.9/5/6/7/8 regression] missing -Wmaybe-uninitialized
                    warning with tree-vrp
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: arnd at linaro dot org
  Target Milestone: ---

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.

Reply via email to