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

            Bug ID: 80824
           Summary: Missing 'variable-is-used-uninitialized' warning
           Product: gcc
           Version: 7.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gccbugs at dima dot secretsauce.net
  Target Milestone: ---

Created attachment 41387
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41387&action=edit
test case

Hi.

I'm using gcc 7.1.0 from Debian/experimental (Debian package gcc-7 version
7.1.0-5).


I ran into a case where an uninitialized variable could be returned from a
function without triggering a warning. With the attached minimized source tst.c
the following does not yield a warning:

  gcc-7 -DCALL -DTEST2 -Wall -Wextra -o /dev/null -c tst.c

Here I initialize some parts of the S structure (s.x), but not others (s.y).
And I return the uninitialized piece: s.y. The extra f() call at the beginning
of g() triggers the bug: taking that call out with

  gcc-7 -DTEST2 -Wall -Wextra -o /dev/null -c tst.c

produces the warning as it should.

Furthermore, initializing s.x in a slightly different way makes the bug go away
as well: this produces the warning also:

  gcc-7 -DCALL -Wall -Wextra -o /dev/null -c tst.c

Finally, it looks like gcc-6 had a similar issue where the extra call to f()
makes the warning go away, but it was fixed in gcc-7: the following misses the
warning:

  gcc-6 -DCALL -DTEST2 -Wall -Wextra -o /dev/null -c tst.c

Maybe the fix to THIS bug would be similar. Thanks!

Reply via email to