------- Comment #8 from roger at eyesopen dot com 2006-03-02 21:39 ------- I think I've found the problem. On mainline, its in tree-scalar-evolution.c at around line 1652, where where handle NEGATE_EXPR in interpret_rhs_modify_expr. The code checks whether the type is SCALAR_FLOAT_TYPE_P, in which case it uses build_real, otherwise it calls build_int_cst_type. Unfortunately, with a complex type, we end up generating a (const_int (complex4) -1) which is very broken. I believe a suitable fix would be to replace this logic with something like fold_convert (type, integer_minus_one_node), which will produce the correct result for integers, reals and complex numbers.
My change to fold-const.c just has stricter error checking and refuses to fold operations of mismatched types, and return NULL_TREE instead. It wasn't a fix, it just hid the problem which is still present but latent on mainline. I think. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26524