This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug sanitizer/81148] UBSAN: two more false positives
- From: "mpolacek at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 22 Jun 2017 13:55:08 +0000
- Subject: [Bug sanitizer/81148] UBSAN: two more false positives
- Auto-submitted: auto-generated
- References: <bug-81148-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81148
--- Comment #10 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
It should've been
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -874,9 +874,24 @@ split_tree (location_t loc, tree in, tree type, enum
tree_code code,
}
if (var)
{
- /* Convert to TYPE before negating. */
- var = fold_convert_loc (loc, type, var);
- var = negate_expr (var);
+ if ((*litp == NULL_TREE
+ && *conp == NULL_TREE
+ && *minus_litp == NULL_TREE)
+ || !INTEGRAL_TYPE_P (type)
+ || TYPE_OVERFLOW_WRAPS (type))
+ {
+ /* Convert to TYPE before negating. */
+ var = fold_convert_loc (loc, type, var);
+ var = negate_expr (var);
+ }
+ else
+ {
+ /* Go back to blank slate. */
+ var = in;
+ *conp = NULL_TREE;
+ *litp = NULL_TREE;
+ *minus_litp = NULL_TREE;
+ }
}
}