https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118337

--- Comment #4 from kargls at comcast dot net ---
(In reply to Jakub Jelinek from comment #3)
> I wonder if the incompatibility isn't just about the iso-c-binding.def (and
> maybe iso-fortran-env.def) changes inserting stuff in the middle rather than
> always just appending it to the end.
> The 42 to 63 change is 21, and there are 21 NAMED_UINTCST entries added into
> the middle of iso-c-binding.def (and one NAMED_FUNCTION added at the end).
> iso-fortran-env.def has 5 NAMED_INTCST and 4 NAMED_UINTCSTs added into the
> middle.
> 
> I don't know if those could be moved to the end and whether it would then
> work fine or not.  And whether this is just about the intrindic modules or
> not.
> Though, even if stuff is just added at the end, I wonder if GCC 15 compiled
> *.mod files that use somewhere the new iso-c-binding etc. entries won't
> cause crashes when compiled by GCC 14.
> So maybe bumping MOD_VERSION is really the only solution.
> Note, diffing those *.def files between GCC 11 and 14, there were no
> additions/removals there.

You may be correct, appending changes to iso_c_binding may
allow a module compiled with 14 to work with 15, but there is
an issue in the opposite direction.

That is, if you compile the following with 15,

% cat foo.f90
   module foo
     use iso_c_binding
     private
     public f_c_string, c_char
  end module

you have

% zcat foo.mod
GFORTRAN module version '15' created from m90types.f90
(() () () () () () () () () () () () () () () () () () () () () () () ()
() () ())
...
('__def_init___iso_c_binding_C_funptr' 0 2
'__def_init___iso_c_binding_C_ptr' 0 4 '__vtab___iso_c_binding_C_funptr'
0 6 '__vtab___iso_c_binding_C_ptr' 0 8 '__vtype___iso_c_binding_C_funptr'
0 7 '__vtype___iso_c_binding_C_ptr' 0 9 'c_char' 0 26 'f_c_string' 0 27)

If you now compile the following with 14

  program bar
    use foo
    print *, len(f_c_string(c_char_'abc'))
  end program

you get

% gfortran14 -o z ss.f90 
f951: internal compiler error: in gfc_intrinsic_function_by_id, at
fortran/intrinsic.cc:1069
0x247159ab9 __libc_start1
        /usr/src/lib/libc/csu/libc_start1.c:157
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

The ICE is similar to what you report.  Even if the module is arranged
to prevent the ICE. 14's libgfortran.so does not contain f_c_string(),
so it will not compile due to a missing reference.

Reply via email to