------- Comment #4 from fxcoudert at gcc dot gnu dot org 2007-08-10 15:31 ------- The problem with integer kind is from the string length:
character(2_8) :: c(2) integer :: i c = "aa" print *, c .eq. "aa" call foo ((/(c(i), i = 1,2)/)) print *, c .eq. "aa" contains subroutine foo (c) character(*), dimension(:) :: c end subroutine foo end If you compile it and set a breakpoint on the translation of the string comparison (which is trans-expr.c:1172), and print out the tree that is the length of c (lse.string_length), you get the first time: <integer_cst 0x2b81534a6930 type <integer_type 0x2b81531d45b0 int4> constant invariant 2> $3 = void which is correct, while the second time you get: <integer_cst 0x2b81534a61b0 type <integer_type 0x2b81531d4750 int8> constant invariant 2> which is wrong: the charlen type is int4, not int8. Somehow, the conjunction of function call and temporary produces this, because if you remove either the function call or the need for a temporary, the code is then correct. >From what I seem there is a cl->backend_decl somewhere (or a string_length) that is generated refering to this int8 constant, which should never happen. I haven't been able to find out where this happens, though. PS: in the mean time, I've found what I think is an unrelated bug. This is the only occurrence that I could find of an cl->backend_decl with wrong type, but it doesn't fix this bug ;-) Index: trans-expr.c =================================================================== --- trans-expr.c (revision 127334) +++ trans-expr.c (working copy) @@ -1855,6 +1851,7 @@ gfc_conv_aliased_arg (gfc_se * parmse, g gfc_array_index_type); tmp = fold_build2 (MINUS_EXPR, gfc_array_index_type, tmp, tmp_se.expr); + tmp = fold_convert (gfc_charlen_type_node, tmp); expr->ts.cl->backend_decl = tmp; break; -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32937