[Bug fortran/59997] c_pointer = c_loc(...) internal compiler error

dominiq at lps dot ens.fr gcc-bugzilla@gcc.gnu.org
Sat Apr 11 12:30:00 GMT 2015


--- Comment #4 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
> The above patch is quite small and perhaps solves the problem in branch 4-8.

> I've coded it before I read the code convention rules for patches.
> In case the patch indeed solves the problem, we'll adjust it accordingly.

I have tested the following patch (test for fsym->as as done elsewhere)

--- ../4.8_clean/gcc/fortran/trans-expr.c    2015-03-26 14:08:19.000000000
+++ gcc/fortran/trans-expr.c    2015-04-11 10:59:51.000000000 +0200
@@ -3730,7 +3730,7 @@ conv_isocbinding_procedure (gfc_se * se,
       /* We should want it to do g77 calling convention.  */
       f = (fsym != NULL)
         && !(fsym->attr.pointer || fsym->attr.allocatable)
-        && fsym->as->type != AS_ASSUMED_SHAPE;
+        && fsym->as && fsym->as->type != AS_ASSUMED_SHAPE;
       f = f || !sym->attr.always_explicit;

       gfc_conv_array_parameter (se, arg->expr, f, NULL, NULL, NULL);

For the test case you should have a look at
https://gcc.gnu.org/wiki/HowToPrepareATestcase, in particular to the section {
dg-do <action> }:

! { dg-do compile } 

is equivalent to compiling the code with -S, so there is no need for the line

+! { dg-options "-c" }

Now when fixing an ICE on valid code, one has to check that the ICE (not good)
is not replaced with wrong code (evil). Fortunately the test
gfortran.dg/c_loc_test_20.f90 yields an ICE without the patch, but compiles and
runs with it.

I am planning to answer your post on fortran@gcc.gnu.org later today.

More information about the Gcc-bugs mailing list