This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/60357] [F08] structure constructor with unspecified values for allocatable components
- From: "janus at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 29 Dec 2014 16:42:01 +0000
- Subject: [Bug fortran/60357] [F08] structure constructor with unspecified values for allocatable components
- Auto-submitted: auto-generated
- References: <bug-60357-4 at http dot gcc dot gnu dot org/bugzilla/>
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.