[cfe-dev] [LLVMdev] proposal for exploiting undefined behavior much more aggressively

annulen at yandex.ru annulen at yandex.ru
Fri Jul 27 01:35:45 PDT 2012

27.07.12, 03:30, "Chris Lattner" <clattner at apple.com>:

>On Jul 26, 2012, at 9:58 AM, John Regehr wrote:
>> http://blog.regehr.org/archives/761
>Its an interesting post, but Id like to point out that it is a non-goal for the project to be actively hostile to users of the compiler.  :)  It is useful to have debugging tools for people who really care, but 'exploiting' undefined behavior just for the sake of breaking code is a non-goal.
>A specific example is code like this (which is quite common):
>int ftoi(float F) {
>  return *(int*)&F;
>This is a violation of the C spec, due to type-based aliasing issues (the right approach is to use a union).  That said, we go out of our way to not break this sort of idiom, because it is obvious to the compiler and actively hostile to a widely used pattern in dusty deck code.

This behavior could be made optional, e.g. if someone has checked the code and found it UB-free he could allow aggressive UB exploiting.


More information about the cfe-dev mailing list