[llvm-bugs] [Bug 50236] New: `-Wsometimes-uninitialized` false positive for assignment

via llvm-bugs llvm-bugs at lists.llvm.org
Wed May 5 19:33:09 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=50236

            Bug ID: 50236
           Summary: `-Wsometimes-uninitialized` false positive for
                    assignment
           Product: new-bugs
           Version: 12.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: xtkoba at gmail.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org

Created attachment 24832
  --> https://bugs.llvm.org/attachment.cgi?id=24832&action=edit
Repro

Compiling the attached C source (named sometimes.c) gives the following
warning:

sometimes.c:8:7: warning: variable 'a' is used uninitialized whenever 'if'
condition is false [-Wsometimes-uninitialized]
  if (!c) c = foo(&a);
      ^~
sometimes.c:9:7: note: uninitialized use occurs here
  b = a;
      ^
sometimes.c:8:3: note: remove the 'if' if its condition is always true
  if (!c) c = foo(&a);
  ^~~~~~~~
sometimes.c:7:8: note: initialize the variable 'a' to silence this warning
  int a, b;
       ^
        = 0
1 warning generated.

At line 9, the value of sometimes-uninitialized variable `a` is only assigned
to another variable `b`, and so it should not be warned until the value is
actually used.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210506/9925cccb/attachment-0001.html>


More information about the llvm-bugs mailing list