[cfe-commits] c bitfield issue

Daniel Dunbar daniel at zuster.org
Mon Dec 15 15:06:44 PST 2008


I was looking as well and reached the same conclusion:
--
ddunbar at lordcrumb:tmp$ cat t.c
int main() {
  struct {
    signed char f0 : 5;
    signed char f1 : 3;
  } l0;

  l0.f0 = 0xF;
  l0.f1 = 0x3;

  return l0.f1;
}
ddunbar at lordcrumb:tmp$ gcc -O2 t.c && ./a.out; echo $?
3
ddunbar at lordcrumb:tmp$ ccc -O2 t.c && ./a.out; echo $?
255
ddunbar at lordcrumb:tmp$ clang -emit-llvm-bc -o - t.c | opt
-std-compile-opts | llvm-dis
; ModuleID = '<stdin>'
target datalayout =
"e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
target triple = "i386-apple-darwin10"

define i32 @main(...) nounwind readnone {
entry:
	ret i32 3
}
--

Eli, want to look more or should I file?

 - Daniel


On Mon, Dec 15, 2008 at 2:58 PM, Eli Friedman <eli.friedman at gmail.com> wrote:
> On Mon, Dec 15, 2008 at 2:31 PM, Fariborz Jahanian <fjahanian at apple.com> wrote:
>> I ran into this bug, having to do with 'signed char' bitfield. Is this
>> a known issue/problem
>> with clang?
>
> I took a quick look, and it appears to be an bug in LLVM CodeGen,
> rather than clang.  I'll try to reduce it and file a bug.
>
> -Eli
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>



More information about the cfe-commits mailing list