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

            Bug ID: 125391
           Summary: [16 Regression] ICE on derived type (with final) array
                    assignment inside polymorphic class
           Product: gcc
           Version: 16.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: federico.perini at gmail dot com
  Target Milestone: ---

Created attachment 64502
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=64502&action=edit
minimal example reproducing the issue.

Verify on Compiler Explorer at: https://godbolt.org/z/63errv1sP

I found this bug after MSYS2 upgraded to gfortran 16.1, but the same is still
present on trunk (see Compiler Explorer). 

> in gimplify_var_or_parm_decl, at gimplify.cc:3426 (16.1) 
> in gimplify_var_or_parm_decl, at gimplify.cc:3266 (trunk, 26/5/20) 

Happens when: 
- a derived type `inner` has `final :: ` procedure, even empty;
- wrapper type `outer` contains `type(inner), allocatable :: array(:)`, may or
may not have a `final ::`
- polymorphic procedure has `class(outer), intent(inout)`, not necessarily
type-bound
- inside the procedure, assignment happens: `this%array = [constructor]` or
`this%array = that%array`

The bug does not appear on gfortran-15 or previous versions. I've tried since
gfortran-7 approximately. 

Thanks for the great work on gfortran!
Best regards, 
Federico

Reply via email to