[cfe-dev] Determining if it is a bug in Clang or my code

Chris Smith chrsmith at google.com
Thu Apr 30 12:31:43 PDT 2015


Hello,

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

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

My questions are:

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

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

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

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?

Any insight would be appreciated.

Thanks,
-Chris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150430/621419c6/attachment.html>


More information about the cfe-dev mailing list