[LLVMdev] ud2 and lack of warning messages

Sean Silva chisophugis at gmail.com
Tue Dec 3 18:49:37 PST 2013


Doing this would make clang's diagnostic output dependent on the
optimization level, which is absolutely verboten.

Also, a ud2 doesn't mean your program has a bug, and I doubt an asm-level
diagnostic would be useful to anyone.

A ud2 just means "if control flow ever reaches this point, the program has
undefined behavior"; in that sense, they don't even have to be emitted.

btw, compiling with -fsanitize=undefined should turn most/all of those
ud2's into runtime checks that will give you a nice diagnostic if they are
violated.

-- Sean Silva


On Tue, Dec 3, 2013 at 8:58 PM, Mikael Lyngvig <mikael at lyngvig.org> wrote:

> Is it just me or would it be nifty if Clang emitted a warning message when
> it generates an "ud2" (UnDefined2) instruction.  I know this is
> x86-specific, but it would be sort of nice to know up front.  After all,
> the compiler knows perfectly well that it is outputting an "ud2"
> instruction and I'm pretty sure almost every programmer out there would
> like to share the unhappy news.
>
>
> -- Mikael
>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20131203/0cd9e6b8/attachment.html>


More information about the llvm-dev mailing list