public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/106507] New: Invalid structure constructor for extending derive type
@ 2022-08-02 17:55 baradi09 at gmail dot com
  0 siblings, 0 replies; only message in thread
From: baradi09 at gmail dot com @ 2022-08-02 17:55 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 106507
           Summary: Invalid structure constructor for extending derive
                    type
           Product: gcc
           Version: 12.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: baradi09 at gmail dot com
  Target Milestone: ---

The following snippet triggers a compilation error

test.f90:17:25:

   17 |     inst = type2("test", 1)
      |                         1
Error: Too many components in structure constructor at (1)

when compiled with

gfortran -c test.f90

although being standard compliant. The problem seems to be the deferred length
character component. If the component is changed to fixed length (but still has
the allocatable attribute), the compiler happily compiles it.

--> test.f90 <--
module mod2
  implicit none

  type :: type1
    character(:), allocatable :: name
  end type type1

  type, extends(type1) :: type2
    integer :: data
  end type

contains

  subroutine mysub()

    type(type2) :: inst
    inst = type2("test", 1)

  end subroutine mysub

end module mod2

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-08-02 17:55 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-02 17:55 [Bug fortran/106507] New: Invalid structure constructor for extending derive type baradi09 at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).