re PR sanitizer/64344 ([UBSAN] ICE with -fsanitize=float-cast-overflow [ICE in -fsani...
authorJakub Jelinek <jakub@redhat.com>
Mon, 5 Jan 2015 21:46:31 +0000 (22:46 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 5 Jan 2015 21:46:31 +0000 (22:46 +0100)
commite534110031564716a1e495a38bf8d893b23a5993
tree0fb2cd367e6916c7cd83f6635fec9facebcc58a5
parent15aed8c4609257ea0280553ad2a5946bdaf06ec9
re PR sanitizer/64344 ([UBSAN] ICE with -fsanitize=float-cast-overflow [ICE in -fsanitize=float-cast-overflow])

PR sanitizer/64344
* ubsan.h (ubsan_instrument_float_cast): Add ARG argument.
* ubsan.c (ubsan_instrument_float_cast): Add ARG argument, pass
it to libubsan handler instead of EXPR.  Fold comparisons earlier,
if the result is integer_zerop, return NULL_TREE.
* convert.c (convert_to_integer): Pass expr as ARG.
c/
* c-typeck.c (convert_for_assignment, c_finish_return): For
-fsanitize=float-cast-overflow casts from REAL_TYPE to integer/enum
types also set in_late_binary_op around convert call.
* c-convert.c (convert): For -fsanitize=float-cast-overflow REAL_TYPE
to integral type casts, if not in_late_binary_op, pass c_fully_fold
result on expr as last argument to ubsan_instrument_float_cast,
if in_late_binary_op, don't use c_save_expr but save_expr.
testsuite/
* c-c++-common/ubsan/pr64344-1.c: New test.
* c-c++-common/ubsan/pr64344-2.c: New test.

From-SVN: r219201
gcc/ChangeLog
gcc/c/ChangeLog
gcc/c/c-convert.c
gcc/c/c-typeck.c
gcc/convert.c
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/ubsan/pr64344-1.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/ubsan/pr64344-2.c [new file with mode: 0644]
gcc/ubsan.c
gcc/ubsan.h