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

            Bug ID: 127146
           Summary: [PDT] Intrinsic structure constructor of extended PDT
                    mishandles inherited components
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: a.shahmoradi at gmail dot com
  Target Milestone: ---

The PDT default constructor fails with two fundamentally different types of
errors depending on the form of PDT object initialization. The title of this
bug report corresponds to the second of the two errors commented below (the
first is an ICE):

```
module mod_pdt

    implicit none

    integer, parameter :: IK = kind(1)

    type :: pdt_parent(IKP)
        integer, kind :: IKP
        integer(IKP) :: ivalp
    end type

    type, extends(pdt_parent) :: pdt_child(IKC)
        integer, kind :: IKC
        integer(IKC) :: ivalc
    end type

end module mod_pdt

    use mod_pdt

    implicit none

    !!  Error 1:
    !!  x86-64 gfortran (trunk) - 357ms
    !!  double free or corruption (fasttop)
    !!  f951: internal compiler error: Aborted
    !!  malloc_consolidate(): unaligned fastbin chunk detected
    !!  gfortran: internal compiler error: f951 terminated by signal 6
(Aborted)
    !!  Program terminated with signal: SIGSEGV
    !!  Compiler returned: 139
    !!
    !type(pdt_child(IKP = IK, IKC = IK)) :: child = pdt_child(IKP = IK, IKC =
IK)(ivalp = 1, ivalc = 2)

    type(pdt_child(IKP = IK, IKC = IK)) :: child

    !!  Error 2:
    !!     35 |     child = pdt_child(IKP = IK, IKC = IK)(ivalp = 1, ivalc = 2)
    !!        |                                                             1
    !!  Error: Component 'ivalc' is initialized twice in the structure
constructor at (1)
    child = pdt_child(IKP = IK, IKC = IK)(ivalp = 1, ivalc = 2)

end
```

This example can be tested at: https://godbolt.org/z/P88rKKTad
  • [Bug fortran/127146] New: [PDT]... a.shahmoradi at gmail dot com via Gcc-bugs

Reply via email to