[LLVMbugs] [Bug 13093] New: -Wsometimes-uninitialized triggers on compile time constant branches with fallthrough

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Jun 12 11:00:59 PDT 2012


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

             Bug #: 13093
           Summary: -Wsometimes-uninitialized triggers on compile time
                    constant branches with fallthrough
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: joerg at NetBSD.org
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


Consider:

#define ERR(v)    do { a = (v); if (a) goto y; } while (0)
int f(int c)
{
    int a, b;

    if (c) {
        b = 1;
        goto x;
    }
    ERR(1);
x:
    return b;
y:    return 0;
}

Warnings:
test.c:10:2: warning: variable 'b' is used uninitialized whenever 'do' loop
exits because its condition is false [-Wsometimes-uninitialized]
        ERR(1);
        ^~~~~~
test.c:1:54: note: expanded from macro 'ERR'
#define ERR(v)  do { a = (v); if (a) goto y; } while (0)
                                                      ^
test.c:12:9: note: uninitialized use occurs here
        return b;
               ^
test.c:10:2: note: remove the condition if it is always true
        ERR(1);
        ^
test.c:1:54: note: expanded from macro 'ERR'
#define ERR(v)  do { a = (v); if (a) goto y; } while (0)
                                                      ^
test.c:4:10: note: initialize the variable 'b' to silence this warning
        int a, b;
                ^
                 = 0


This set-and-check pattern can be found in the BIND source code.

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