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

markeggleston at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |markeggleston at gcc dot 
gnu.org

--- Comment #3 from markeggleston at gcc dot gnu.org ---
Using the patch comment 2 and the example program:

program p
   type t
      character :: a
      integer :: b
      integer :: c(t(1))
   end type
   type(t) :: z = t('a', 2, [3])
end

    5 |       integer :: c(t(1))
      |                    1
Error: No initializer for component 'b' given in the structure constructor at
(1)

Adding a second initializer:

program p
   type t
      character :: a
      integer :: b
      integer :: c(t(1, "rubbish"))
   end type
   type(t) :: z = t('a', 2, [3])
end

    5 |       integer :: c(t(1))
      |                    1
Error: No initializer for component 'c' given in the structure constructor at
(1)

There is no reporting of incompatible types i.e, integer(4) to character(1) and
character(7) to integer(4).

Finally if all initializers are given:

program p
   type t
      character :: a
      integer :: b
      integer :: c(t(1, "rubbish", 7.5))
   end type
   type(t) :: z = t('a', 2, [3])
end

The result is an ICE without a call stack:

gfortran: internal compiler error: Segmentation fault signal terminated program
f951
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://gcc.gnu.org/bugs/> for instructions.

The declaration of component c of the derived type t is intended to be an
array, if it is then I would expect the use of derived type to be illegal.

An error is given if a different derived type is used:

program p
   type t2
   end type
   type t
      character :: a
      integer :: b
      integer :: c(t2())
   end type
   type(t) :: z = t('a', 2, [3])
end


    7 |       integer :: c(t2())
      |                   1
Error: Expression at (1) must be of INTEGER type, found DERIVED

This is the error or something like it that should be reported when the derived
type t is used as the array spec.

Where the type t constructor is used in the declaration of type t I'm having
difficulty in stopping it from constructing a structure and consequently
resulting in an ICE.

Reply via email to