Hello, this bug is not a regression, but the patch shouldn't wreck the compiler too much on the other hand. The problem is a wrong number of arguments while generating code for the ichar intrinsic. The correct number is 2 without the kind argument and 3 with it. The attached patch uses the gfc_intrinsic_argument_list_length function like it's done for other intrinsics.
Regression tested on x86_64-unknown-linux-gnu. OK for trunk/4.8/4.7? Mikael
2014-02-14 Mikael Morin <mik...@gcc.gnu.org> PR fortran/59599 * trans-intrinsic.c (gfc_conv_intrinsic_ichar): Calculate the number of arguments. 2014-02-14 Mikael Morin <mik...@gcc.gnu.org> PR fortran/59599 * gfortran.dg/ichar_3.f90: New test.
diff --git a/gcc/fortran/trans-intrinsic.c b/gcc/fortran/trans-intrinsic.c index 1eb9490..cff8e89 100644 --- a/gcc/fortran/trans-intrinsic.c +++ b/gcc/fortran/trans-intrinsic.c @@ -4689,8 +4689,10 @@ static void gfc_conv_intrinsic_ichar (gfc_se * se, gfc_expr * expr) { tree args[2], type, pchartype; + int nargs; - gfc_conv_intrinsic_function_args (se, expr, args, 2); + nargs = gfc_intrinsic_argument_list_length (expr); + gfc_conv_intrinsic_function_args (se, expr, args, nargs); gcc_assert (POINTER_TYPE_P (TREE_TYPE (args[1]))); pchartype = gfc_get_pchar_type (expr->value.function.actual->expr->ts.kind); args[1] = fold_build1_loc (input_location, NOP_EXPR, pchartype, args[1]);
! { dg-do compile } ! ! PR fortran/59599 ! The call to ichar was triggering an ICE. ! ! Original testcase from Fran Martinez Fadrique <fmarti...@gmv.com> character(1) cpk(2) integer res(2) cpk = 'a' res = ichar( cpk, kind=1 ) print *, ichar( cpk, kind=1 ) end