[Bug sanitizer/82072] sanitizer does not detect an overflow from LLONG_MIN
mpolacek at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Sep 4 13:19:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82072
--- Comment #13 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
So maybe
--- a/gcc/convert.c
+++ b/gcc/convert.c
@@ -886,6 +886,10 @@ convert_to_integer_1 (tree type, tree expr, bool dofold)
break;
case NEGATE_EXPR:
+ /* Using unsigned arithmetic may hide overflow bugs. */
+ if (sanitize_flags_p (SANITIZE_SI_OVERFLOW))
+ break;
+ /* Falls through. */
case BIT_NOT_EXPR:
/* This is not correct for ABS_EXPR,
since we must test the sign before truncation. */
@@ -902,12 +906,7 @@ convert_to_integer_1 (tree type, tree expr, bool dofold)
TYPE_UNSIGNED (typex));
if (!TYPE_UNSIGNED (typex))
- {
- /* Using unsigned arithmetic may hide overflow bugs. */
- if (sanitize_flags_p (SANITIZE_SI_OVERFLOW))
- break;
- typex = unsigned_type_for (typex);
- }
+ typex = unsigned_type_for (typex);
return convert (type,
fold_build1 (ex_form, typex,
convert (typex,
More information about the Gcc-bugs
mailing list