<div dir="ltr"><div>Invalidating this bug with a language technicality would be a great way out. :)<br></div><br>But I don't see anything in the standard to suggest that a plain 'int' bitfield is any different than a 'signed int' bitfield, and even if that was true, I don't see any difference in codegen whether I specify 'signed' explicitly or not. So at the least, clang or llvm still has a bug for the explicit 'signed' case from what I can tell.<br>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Nov 15, 2013 at 8:41 PM, Mark Lacey <span dir="ltr"><<a href="mailto:mark.lacey@apple.com" target="_blank">mark.lacey@apple.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><br><div><div class="im"><div>On Nov 15, 2013, at 3:42 PM, Kay Tiong Khoo <<a href="mailto:kkhoo@perfwizard.com" target="_blank">kkhoo@perfwizard.com</a>> wrote:</div>
<br><blockquote type="cite"><div dir="ltr">I've been diagnosing this bug:<br><a href="http://llvm.org/bugs/show_bug.cgi?id=17827" target="_blank">http://llvm.org/bugs/show_bug.cgi?id=17827</a><br><br>Summary: I think the following program miscompiles at -O1 because the fact that 'f0' is a signed 3-bit value is lost in the unoptimized LLVM IR. How do we fix this?<br>
</div></blockquote><div><br></div></div><div>I don’t have the C/C++ standards in front of me but IIRC whether a char/short/int/long/long long bitfield is signed or unsigned is implementation defined. You need to explicitly specify signed or unsigned in order to have any guarantee of the signedness, e.g. signed int.</div>
<br><blockquote type="cite"><div class="im"><div dir="ltr">
<br><span style="font-family:courier new,monospace">$ cat bitfield.c</span><br><span style="font-family:courier new,monospace">/* %struct.S = type { i8, [3 x i8] } ??? */<br>struct S {<br>  int f0:3;<br>} a;<br><br>int foo (int p) {<br>

  struct S c = a;<br>  c.f0 = p & 6;<br>  return c.f0 < 1;<br>}<br><br>int main () {<br>  return foo (4);<br>}</span><br><br><br></div></div>
_______________________________________________<br>LLVM Developers mailing list<br><a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br></blockquote></div><br></div></blockquote></div><br></div>