[LLVMbugs] [Bug 9626] New: Duplicate and confusing warnings from -Wuninitialized

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Apr 4 12:07:52 PDT 2011


http://llvm.org/bugs/show_bug.cgi?id=9626

           Summary: Duplicate and confusing warnings from -Wuninitialized
           Product: clang
           Version: unspecified
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: chandlerc at gmail.com
                CC: llvmbugs at cs.uiuc.edu


This is partially my fault. =[ But I'm not sure what exactly to do here. I
added a special check for -Wuninitialized with self-initialization cases. The
recent changes to the CFG-based uninitialized checker now warn for the same
construct, resulting in this:

% cat x.cc
void test() {
  int x = x + 42;
  (void)x;
}

% ./bin/clang -fsyntax-only -Wuninitialized x.cc
x.cc:2:11: warning: variable 'x' is uninitialized when used within its own
initialization [-Wuninitialized]
  int x = x + 42;
      ~   ^
x.cc:2:11: warning: variable 'x' is possibly uninitialized when used here
[-Wuninitialized]
  int x = x + 42;
          ^
x.cc:2:3: note: variable 'x' is declared here
  int x = x + 42;
  ^
x.cc:2:17: note: add initialization to silence this warning
  int x = x + 42;
                ^
                 = 0
2 warnings generated.

At the very least we shouldn't generate two warnings here, but more-over:

- The first is much more concise
- The declaration note is general unhelpful when warning on the initializer
- The fixit hint is just nuts here. =/

I wonder if we should stick to the custom logic for the initializer case for
now? Or is there an easy way to fix these in the CFG?

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list