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

             Bug #: 14407
           Summary: Conditional assignment omitted when compiling a C
                    program with llvm-gcc
           Product: new-bugs
           Version: 2.7
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: release blocker
          Priority: P
         Component: new bugs
        AssignedTo: [email protected]
        ReportedBy: [email protected]
                CC: [email protected]
    Classification: Unclassified


When compiling our application, I found that llvm-gcc frontend omitted the
conditional assignment. Please refer to the sample code snippet:

#include <stdio.h>

typedef struct {
        int i1;
        int i2;
        int i3;
        int i4;
} Entry1;

typedef struct {
        int i1;
        int i2;
        int i3;
} Entry2;

int TestEntry1(int bCheck)
{
        void* pEntry1 = 0;
        void* pEntry2 = (bCheck != 0) ? ((void*)(((Entry1*) pEntry1) + 1)) :
((void*)(((Entry2*) pEntry1) + 1));
        return (pEntry2 - pEntry1);
}

int main(int argc, const char * argv[])
{
        printf("TestEntry1(1): %d\n", TestEntry1(1));
        printf("TestEntry1(0): %d\n", TestEntry1(0));
        return 0;
}

$llvm-gcc ca.c
$./a.out
TestEntry1(1): 16
TestEntry1(0): 16

while the expected output is:
TestEntry1(1): 16
TestEntry1(0): 12

After reviewing the assemble code, the "(bCheck != 0)" judgement is missing.
The other frontend "clang" works well.

-- 
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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to