[cfe-commits] [PATCH] Add -fcatch-undefined-behavior runtime library
Richard Smith
richard at metafoo.co.uk
Thu Oct 4 01:36:06 PDT 2012
Hi,
The attached patches to compiler-rt and Clang add a new runtime library
which -fcatch-undefined-behavior will call into when it detects undefined
behavior. Output looks like this (complete with Clang-style highlighting if
it's writing to a terminal):
$ echo '
typedef int X;
int main(int argc, char**) {
return *(X*)argc;
}' | ./bin/clang -x c++ - -fcatch-undefined-behavior
$ ./a.out
*<stdin>:4:10: fatal error: load of misaligned address 0x1 for type 'X'
(aka 'int'), which requires 4 byte alignment*
zsh: illegal hardware instruction (core dumped) ./a.out
$
I've left -ftrapv's behavior alone, for now at least.
Review appreciated!
Thanks,
Richard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20121004/930e9d80/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ubsan-clang.diff
Type: application/octet-stream
Size: 30917 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20121004/930e9d80/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ubsan-compiler-rt.diff
Type: application/octet-stream
Size: 43533 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20121004/930e9d80/attachment-0001.obj>
More information about the cfe-commits
mailing list