Commit c10166c4 by Roger Sayle Committed by Roger Sayle

re PR middle-end/21709 (ICE on compile-time complex NaN)


	PR middle-end/21709
	* fold-const.c (const_binop): Check for division by zero during
	complex division.

	* gcc.dg/pr21709-1.c: New test case.

From-SVN: r100188
parent 67730e23
2005-05-25 Roger Sayle <roger@eyesopen.com>
PR middle-end/21709
* fold-const.c (const_binop): Check for division by zero during
complex division.
2005-05-26 Ian Lance Taylor <ian@airs.com> 2005-05-26 Ian Lance Taylor <ian@airs.com>
* reload1.c (verify_initial_elim_offsets): Add braces to avoid * reload1.c (verify_initial_elim_offsets): Add braces to avoid
......
...@@ -1600,33 +1600,36 @@ const_binop (enum tree_code code, tree arg1, tree arg2, int notrunc) ...@@ -1600,33 +1600,36 @@ const_binop (enum tree_code code, tree arg1, tree arg2, int notrunc)
case RDIV_EXPR: case RDIV_EXPR:
{ {
tree t1, t2, real, imag;
tree magsquared tree magsquared
= const_binop (PLUS_EXPR, = const_binop (PLUS_EXPR,
const_binop (MULT_EXPR, r2, r2, notrunc), const_binop (MULT_EXPR, r2, r2, notrunc),
const_binop (MULT_EXPR, i2, i2, notrunc), const_binop (MULT_EXPR, i2, i2, notrunc),
notrunc); notrunc);
t = build_complex (type, t1 = const_binop (PLUS_EXPR,
const_binop const_binop (MULT_EXPR, r1, r2, notrunc),
(INTEGRAL_TYPE_P (TREE_TYPE (r1)) const_binop (MULT_EXPR, i1, i2, notrunc),
? TRUNC_DIV_EXPR : RDIV_EXPR, notrunc);
const_binop (PLUS_EXPR, t2 = const_binop (MINUS_EXPR,
const_binop (MULT_EXPR, r1, r2, const_binop (MULT_EXPR, i1, r2, notrunc),
notrunc), const_binop (MULT_EXPR, r1, i2, notrunc),
const_binop (MULT_EXPR, i1, i2, notrunc);
notrunc),
notrunc), if (INTEGRAL_TYPE_P (TREE_TYPE (r1)))
magsquared, notrunc), {
const_binop real = const_binop (TRUNC_DIV_EXPR, t1, magsquared, notrunc);
(INTEGRAL_TYPE_P (TREE_TYPE (r1)) imag = const_binop (TRUNC_DIV_EXPR, t2, magsquared, notrunc);
? TRUNC_DIV_EXPR : RDIV_EXPR, }
const_binop (MINUS_EXPR, else
const_binop (MULT_EXPR, i1, r2, {
notrunc), real = const_binop (RDIV_EXPR, t1, magsquared, notrunc);
const_binop (MULT_EXPR, r1, i2, imag = const_binop (RDIV_EXPR, t2, magsquared, notrunc);
notrunc), if (!real || !imag)
notrunc), return NULL_TREE;
magsquared, notrunc)); }
t = build_complex (type, real, imag);
} }
break; break;
......
2005-05-25 Roger Sayle <roger@eyesopen.com>
PR middle-end/21709
* gcc.dg/pr21709-1.c: New test case.
2005-05-25 Ziemowit Laski <zlaski@apple.com> 2005-05-25 Ziemowit Laski <zlaski@apple.com>
Mike Stump <mrs@apple.com> Mike Stump <mrs@apple.com>
......
/* PR middle-end/21709 */
/* { dg-do compile } */
/* { dg-options "-O2" } */
double _Complex f(void) { return 1.0iF / 0.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