This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/60357] [F08] structure constructor with unspecified values for allocatable components


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

--- Comment #10 from janus at gcc dot gnu.org ---
(In reply to Andre Vehreschild from comment #9)
> I just need to
> figure, if allocating the component explicitly is valid in Fortran.

For sure. I think both the examples in comment 4 and 5 are actually valid
Fortran code.

In order to make sure we're talking about the same thing, let's have a look at
the following code:

Type A
  integer :: X = 1
  integer, allocatable :: y
end type
Type(A) :: Me
allocate(Me%y)
print *,"A"
Me = A(X=1, y=2)
print *,"B"
print *, Me%y
end

This is a variant of the example above that produced the segfault. I inserted
some print statements in order to debug it. It prints at runtime:

 A
 B

Program received signal SIGSEGV: Segmentation fault - invalid memory reference.


This shows clearly that the segfault occurs when we try to access Me%y in the
last print statement, meaning that it is probably unallocated although it
clearly should be.

-fdump-tree-original shows that the problem is in the translation of the
structure constructor assignment, which apparently leaves the y-component
unallocated.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]