<div dir="ltr">Can you see if the the invalid opcode is ud2a? Clang sometimes emits those after encountering certain kinds of UB.<div><br></div><div>I think the most common is falling off the end of a function that is supposed to return a value. If you compile your code with -Wreturn-type (it should be on by default), you should see a warning for it, but not if the code is in a system header. There are other more obscure ways to trigger it, like passing non-POD objects through a vararg pack, but my money is on -Wreturn-type.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Apr 30, 2015 at 12:31 PM, Chris Smith <span dir="ltr"><<a href="mailto:chrsmith@google.com" target="_blank">chrsmith@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hello,<div><br></div><div>I've been working on an operating-system as a hobby project for a few months now, and finally tried converting the codebase to Clang. While the code compiles fine, I now get a surprising Interrupt 0x06 "Invalid Opcode" being fired when executing some C++ code. (Running either under bochs and qemu.)</div><div><br></div><div>The same codebase works fine when compiled under GCC, the faulty code(?) only happens when built under Clang. The part of the code isn't invoking any assembly (inline or otherwise), and the C++ itself is fairly straight forward. (See below.)</div><div><br></div><div>My questions are:</div><div><br></div><div>- Is the fact this interrupt firing while executing pure C++ code proof of a compiler bug? Or is it possible to generate invalid opcodes through using undefined C++ behavior, etc.</div><div><br></div><div>- How likely is it that this is actually a Clang codegen bug? I worked on the F# compiler at Microsoft, and know quite well that "I found a bug in the compiler" is latin for "I don't understand how this language works"; though the fact the code is triggering a CPU interrupt is concerning.</div><div><br></div><div>- Would it be worth while to distill my os-project down and try to produce a minimal repro? If so, where should I send it?</div><div><br></div><div>As for the code itself, the problem seems to be occurring in my implementation of printf. I'm using variadic template arguments to do it in a typesafe way. Is "variadic template codegen for 32-bit" a particularly rough area of the Clang/LLVM codebase?</div><div><br></div><div>Any insight would be appreciated.</div><div><br></div><div>Thanks,</div><div>-Chris</div></div>
<br>_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br></div>