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/28154] SPREAD (and friends) on unallocated arrays


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

Sean Santos <quantheory at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |quantheory at gmail dot com

--- Comment #1 from Sean Santos <quantheory at gmail dot com> ---
I don't think that the original bug report here is quite right. See here:

real,allocatable :: bar(:,:),foo(:)
allocate(foo(0))
bar = spread(foo,dim=1,ncopies=1)
print *, shape(bar)
end

This prints:

           1           0

That's perfectly correct; bar is "allocated" according to Fortran semantics,
but of size 0.

However, there's this related case where foo is never allocated, which seems to
be what the OP was talking about:

real,allocatable :: bar(:,:),foo(:)
bar = spread(foo,dim=1,ncopies=1)
print *, shape(bar)
end

This is not a legal use of a non-allocated variable, but "-fcheck=all" misses
it. If you run, you get:

           1           1

Which is nonsense.


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