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

Jonathan Roelofs jonathan at codesourcery.com
Thu Apr 30 13:00:53 PDT 2015



On 4/30/15 1:31 PM, Chris Smith wrote:
> 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.

A call of an uninitialized function pointer might do that.

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

Heh.

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

Please do. Here, and llvm.org/bugs are the right places to 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?

Not really.


Jon

>
> Any insight would be appreciated.
>
> Thanks,
> -Chris
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>

-- 
Jon Roelofs
jonathan at codesourcery.com
CodeSourcery / Mentor Embedded



More information about the cfe-dev mailing list