[LLVMbugs] [Bug 7726] New: Invalid codegen for "Conditionals with Omitted Operands" (?:) expression in c++

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Jul 27 14:32:33 PDT 2010


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

           Summary: Invalid codegen for "Conditionals with Omitted
                    Operands" (?:) expression in c++
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: devlists at shadowlab.org
                CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com


When using the "conditional with omitted operands" extension in C++, clang
incorrectly cast the first operand in bool.

Example: 
============

#include <stdio.h>

int main(int argc, char **argv) {
    printf("%p\n", (void *)0xdeadbeef ? : (void *)0xaaaaaa);
    return 0;
}

===========

clang++ will cast '0xdeadbeef' as bool and so the executable will print "0x1"
instead of the pointer value.

When compiling this program as C, the implicit case is not generated and so the
output is correct.

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