Commit 531f0b38 by Richard Biener Committed by Richard Biener

re PR sanitizer/81097 (UBSAN: false positive for not existing negation operator…

re PR sanitizer/81097 (UBSAN: false positive for not existing negation operator and a bogus message)

2017-06-20  Richard Biener  <rguenther@suse.de>

	PR middle-end/81097
	* fold-const.c (split_tree): Fold to type before negating.

	* c-c++-common/ubsan/pr81097.c: New testcase.

From-SVN: r249407
parent c7a980b8
2017-06-20 Richard Biener <rguenther@suse.de>
PR middle-end/81097
* fold-const.c (split_tree): Fold to type before negating.
2017-06-20 David Malcolm <dmalcolm@redhat.com>
* diagnostic-show-locus.c
......
......@@ -853,9 +853,9 @@ split_tree (location_t loc, tree in, tree type, enum tree_code code,
&& code == PLUS_EXPR)
{
/* -X - 1 is folded to ~X, undo that here. Do _not_ do this
when IN is constant. */
*minus_litp = build_one_cst (TREE_TYPE (in));
var = negate_expr (TREE_OPERAND (in, 0));
when IN is constant. Convert to TYPE before negating. */
*minus_litp = build_one_cst (type);
var = negate_expr (fold_convert_loc (loc, type, TREE_OPERAND (in, 0)));
}
else
var = in;
......
2017-06-20 Richard Biener <rguenther@suse.de>
PR middle-end/81097
* c-c++-common/ubsan/pr81097.c: New testcase.
2017-06-20 Richard Biener <rguenther@suse.de>
* gcc.dg/vect/pr65947-9.c: Adjust.
2017-06-20 Prakhar Bahuguna <prakhar.bahuguna@arm.com>
......
/* { dg-do run } */
/* { dg-options "-fsanitize=undefined -fsanitize-undefined-trap-on-error" } */
unsigned int a = 3309568;
unsigned int b = -1204857327;
short c = -10871;
short x;
int main()
{
x = ((short)(~a) | ~c) + ((short)(~b) | ~c);
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment