Confirmed.
Appeared with gcc 3.4.0. Only affects 3.4 branch.
Comment 2rsandifo@gcc.gnu.org
2005-07-27 17:31:28 UTC
This seems to be caused by:
2004-02-15 Roger Sayle <roger@eyesopen.com>
Backport from mainline:
2004-02-07 Roger Sayle <roger@eyesopen.com>
PR middle-end/13696
* fold-const.c (fold_convert): New function to provide type
conversion to the middle-end without using convert.
(negate_expr, associate_trees, size_diffop, omit_one_operand,
operand_equal_for_comparison_p, pedantic_omit_one_operand,
invert_truthvalue, optimize_bit_field_compare, range_binop,
decode_field_reference, make_range, build_range_check, unextend,
fold_truthop, extract_muldiv_1, fold_mathfn_compare,
fold_binary_op_with_conditional_arg, fold_inf_compare,
fold_single_bit_test, fold, multiple_of_p): Replace all calls to
convert with calls to fold_convert.
convert() uses CONVERT_EXPR rather than NOP_EXPR for pointer-to-integer
conversions, but after the patch above, the original <CONVERT_EXPR int foo>
will be "folded" to <NOP_EXPR int foo>.
On 3.4, get_narrower(<NOP_EXPR int foo>) returns "foo", which has
a pointer type, and causes the segfault in shorten_compare().
This was fixed (worked around?) on mainline by:
2004-07-08 Alexandre Oliva <aoliva@redhat.com>
Introduce H8SX support.
....
2004-06-16 Alexandre Oliva <aoliva@redhat.com>
* tree.c (get_narrower): Don't narrow integral types into
non-integral types.
and backporting that patch seems to fix the testcase.
I'm not a tree expert, and I can't find any discussion of Alex's patch:
http://gcc.gnu.org/ml/gcc-patches/2004-06/msg01644.html
so I'm not sure if CONVERT_EXPR really is required here. But given
that this bug is specific to a release branch, and that the branch
is deep into "maintenance only" mode, I think that backporting
Alex's patch is the best fix here. I'm regression testing it now.
Richard
Comment 6rsandifo@gcc.gnu.org
2005-07-28 08:10:25 UTC
Patch applied to 3.4. I also applied the testcase to mainline and 4.0
(where it passes already).
Description lex.augusteijn 2005-07-21 13:45:42 UTC
Seg fault of gcc on the following program: void bar (void) { char *foo; (long long)((int)foo+0) < 0 ; } command use: gcc -c file.cComment 1 Volker Reichelt 2005-07-21 16:36:13 UTC
Comment 2 rsandifo@gcc.gnu.org 2005-07-27 17:31:28 UTC
Comment 6 rsandifo@gcc.gnu.org 2005-07-28 08:10:25 UTC