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

            Bug ID: 122670
           Summary: [PDT] Mismatched types with same name in assignment
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pault at gcc dot gnu.org
  Target Milestone: ---

A minimal reproducer, from Damian Rouson, for the compilation error in
learn-addition.F90 from fiats

Interestingly, the code below compiles cleanly if the "only" clause is removed.
(Added by PRT: it also compiles if the component is not allocatable or the
pdt_type is included directly.). 

$ cat reproducer.f90 
module tensor_m
  implicit none

  type tensor_t(k)
    integer, kind :: k = kind(0.)
    real(k), allocatable :: value_
  end type

contains
  function y(x)
    type(tensor_t) x, y
    y = tensor_t(x%value_)
  end function
end module

  use tensor_m, only : tensor_t, y
  implicit none
  type(tensor_t) desired_output
  desired_output = y(tensor_t(0.))
end

$ gfortran -c reproducer.f90 
reproducer.f90:19:34:

   19 |   desired_output = y(tensor_t(0.))
      |                                  1
internal compiler error: in fold_convert_loc, at fold-const.cc:2793
0x27f880f internal_error(char const*, ...)
        ../../trunk/gcc/diagnostic-global-context.cc:787
0xa851ef fancy_abort(char const*, int, char const*)
        ../../trunk/gcc/diagnostics/context.cc:1806
0x8610b8 fold_convert_loc(unsigned long, tree_node*, tree_node*)
        ../../trunk/gcc/fold-const.cc:2793
0xc1a3b5 gfc_trans_scalar_assign(gfc_se*, gfc_se*, gfc_typespec, bool, bool,
bool, bool)
        ../../trunk/gcc/fortran/trans-expr.cc:11703
0xc37425 gfc_trans_assignment_1
        ../../trunk/gcc/fortran/trans-expr.cc:13428
0xbd54a7 trans_code
        ../../trunk/gcc/fortran/trans.cc:2349
0xc11042 gfc_generate_function_code(gfc_namespace*)
        ../../trunk/gcc/fortran/trans-decl.cc:8152
0xb70ade translate_all_program_units
        ../../trunk/gcc/fortran/parse.cc:7554
0xb70ade gfc_parse_file()
        ../../trunk/gcc/fortran/parse.cc:7876
0xbd1e4f gfc_be_parse_file
        ../../trunk/gcc/fortran/f95-lang.cc:247
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.

$ gfortran --version
GNU Fortran (GCC) 16.0.0 20251111 (experimental)

Reply via email to