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

            Bug ID: 21726
           Summary: -Wundefined-bool-conversion not raised in all cases
                    where optimization is applied
           Product: clang
           Version: 3.5
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected]
    Classification: Unclassified

Hi,

in function indirect() below, no warning for the check of the address of the
reference is raised, but the check is still optimized out at -O1. This is a big
problem for codebases that have such constructs, since it can be hard to track
down the resulting errors at runtime. direct() raises the warning as expected.

int indirect()
{
    int a = 42;
    int &r = a;
    int *p = &r;
    if (p) // no warning!
        return 0;
    else
        return 1;
}

int direct()
{
    int a = 42;
    int &r = a;
    if (&r) // -Wundefined-bool-conversion
        return 0;
    else
        return 1;
}

Best regards,
Martin

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to