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

            Bug ID: 116530
           Summary: ICE with member of namelist renamed by use module
           Product: gcc
           Version: 14.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: philippe.wautelet at cnrs dot fr
  Target Milestone: ---

Hello,

The following code triggers an internal compiler error with gfortran 14.1.0 and
14.2.0:
> cat ice_nml_profilern.f90 
module mod_nml1
  logical :: ldiag

  namelist /nam_nml1/ldiag
end module mod_nml1

module mod_nml2
  logical :: ldiag

  namelist /nam_nml2/ldiag
end module mod_nml2

module mod_interm
  use mod_nml1
end module mod_interm

program ice_nml
  use mod_nml1, ldiag_nml1 => ldiag
  use mod_nml2, ldiag_nml2 => ldiag
  use mod_interm

  integer :: ilu

  read(unit=ilu,nml=nam_nml1)
end program ice_nml

> gfortran ice_nml_profilern.f90 
ice_nml_profilern.f90:24:29:

   24 |   read(unit=ilu,nml=nam_nml1)
      |                             1
internal compiler error: Segmentation fault
0xe10cdf crash_signal
        ../../gcc-14.2.0-srcdir/gcc/toplev.cc:319
0x893878 gfc_build_cstring_const(char const*)
        ../../gcc-14.2.0-srcdir/gcc/fortran/trans-const.cc:124
0x8de9eb transfer_namelist_element
        ../../gcc-14.2.0-srcdir/gcc/fortran/trans-io.cc:1696
0x8e0792 build_dt
        ../../gcc-14.2.0-srcdir/gcc/fortran/trans-io.cc:2012
0x872b87 trans_code
        ../../gcc-14.2.0-srcdir/gcc/fortran/trans.cc:2551
0x8a38b4 gfc_generate_function_code(gfc_namespace*)
        ../../gcc-14.2.0-srcdir/gcc/fortran/trans-decl.cc:7880
0x813e26 translate_all_program_units
        ../../gcc-14.2.0-srcdir/gcc/fortran/parse.cc:7099
0x813e26 gfc_parse_file()
        ../../gcc-14.2.0-srcdir/gcc/fortran/parse.cc:7413
0x86fc0f gfc_be_parse_file
        ../../gcc-14.2.0-srcdir/gcc/fortran/f95-lang.cc:241



I'm not sure it is conforming to the Fortran standard but it shouldn't trigger
an ICE.

I think it could be related to the fix for bug 105847.

This code compiles successfully with versions prior to 14.

Reply via email to