[LLVMbugs] [Bug 9076] New: Spurious warning about uninitialized variable when assigned in condition

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Jan 27 14:18:22 PST 2011


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

           Summary: Spurious warning about uninitialized variable when
                    assigned in condition
           Product: clang
           Version: trunk
          Platform: Macintosh
        OS/Version: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: tjw at omnigroup.com
                CC: llvmbugs at cs.uiuc.edu


This construct produces a warning in clang ToT (r124408):

    int identifier;
    if ((strcmp(name, "foo") == 0 && (identifier = 1)) ||
        (strcmp(name, "bar") == 0 && (identifier = 2))) {
        return identifier;
    }
    return 0;

But the variable is only used on conditional paths were it has been assigned.
Obviously this is a little bit of a "clever" use of C and we can restructure
our use to avoid it, but it might be nice to handle this.

-- 
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