[LLVMbugs] [Bug 14880] New: --bitfield code is computed incorrectly

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Jan 9 12:20:49 PST 2013


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

             Bug #: 14880
           Summary: --bitfield code is computed incorrectly
           Product: clang
           Version: 3.2
          Platform: PC
        OS/Version: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: LLVM Codegen
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: yozh at mx1.ru
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


Code:

===
#include <stdio.h>
#include <stdlib.h>

struct foo {
    int x:31;
    int y:1;
};

static void baz(struct foo* f) {
    --f->x;
    if (f->x < 0)
        exit(1);
}

int main() {
    struct foo f;

    f.x = 1;
    f.y = 0;

    printf("%d %d\n", f.x, f.y);
    baz(&f);
    printf("%d %d\n", f.x, f.y);

    return 0;
}
===

When compiled with clang 3.2 with -O2 on OSX or on Linux, outputs:

===
1 0
0 -1
===

Should output:

===
1 0
0 0
===

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