public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/100650] New: Passing a derived-type array constructor to the reshape intrinsic gives incorrect results
@ 2021-05-18 12:35 here.is.a.gcc.bug at gmail dot com
2023-06-20 22:18 ` [Bug fortran/100650] " damian at archaeologic dot codes
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: here.is.a.gcc.bug at gmail dot com @ 2021-05-18 12:35 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100650
Bug ID: 100650
Summary: Passing a derived-type array constructor to the
reshape intrinsic gives incorrect results
Product: gcc
Version: 11.1.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: here.is.a.gcc.bug at gmail dot com
Target Milestone: ---
Created attachment 50836
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50836&action=edit
A minimum broken example. Needs no special compiler flags.
A type `String` has a `character(:), allocatable` component.
When an array constructor of type `String` is passed to the reshape intrinsic,
the components of the resulting array are incorrect.
The bug does not trigger if the array constructor is used to create a named
array and this named array is passed to the reshape intrinsic.
This affects at least versions 7.4.0, 10.1.0 and 11.1.1 of gfortran.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug fortran/100650] Passing a derived-type array constructor to the reshape intrinsic gives incorrect results
2021-05-18 12:35 [Bug fortran/100650] New: Passing a derived-type array constructor to the reshape intrinsic gives incorrect results here.is.a.gcc.bug at gmail dot com
@ 2023-06-20 22:18 ` damian at archaeologic dot codes
2023-06-21 9:27 ` damian at archaeologic dot codes
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: damian at archaeologic dot codes @ 2023-06-20 22:18 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100650
Damian Rouson <damian at archaeologic dot codes> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |damian at archaeologic dot codes
--- Comment #1 from Damian Rouson <damian at archaeologic dot codes> ---
Here's a shorter reproducer:
% cat reshape-array-constructor.f90
type foo_t
integer, allocatable :: bar(:)
end type
type(foo_t) foo(2,1)
integer :: i, j, n(2,2,1) = reshape([-1,-1,1,1], [2,2,1])
foo = reshape([([(foo_t(merge(0, 1, n(:,i,j) > 0)), i=1,2)], j=1,1)], [2,1])
print *, merge(0, 1, n(:,1,1) > 0), foo(1,1)%bar
print *, merge(0, 1, n(:,2,1) > 0), foo(2,1)%bar
end
% gfortran reshape-array-constructor.f90
% ./a.out
1 1 -358465392 24440
0 0 -358465392 24440
% gfortran --version
GNU Fortran (Homebrew GCC 13.1.0) 13.1.0
Another workaround in the above example is to make n a constant array via
integer, parameter :: n(*,*,*) = reshape([-1,-1,1,1], [2,2,1])
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug fortran/100650] Passing a derived-type array constructor to the reshape intrinsic gives incorrect results
2021-05-18 12:35 [Bug fortran/100650] New: Passing a derived-type array constructor to the reshape intrinsic gives incorrect results here.is.a.gcc.bug at gmail dot com
2023-06-20 22:18 ` [Bug fortran/100650] " damian at archaeologic dot codes
@ 2023-06-21 9:27 ` damian at archaeologic dot codes
2023-06-21 21:10 ` pault at gcc dot gnu.org
2023-06-22 21:24 ` damian at archaeologic dot codes
3 siblings, 0 replies; 5+ messages in thread
From: damian at archaeologic dot codes @ 2023-06-21 9:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100650
--- Comment #2 from Damian Rouson <damian at archaeologic dot codes> ---
Is this related to PR 49324?
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug fortran/100650] Passing a derived-type array constructor to the reshape intrinsic gives incorrect results
2021-05-18 12:35 [Bug fortran/100650] New: Passing a derived-type array constructor to the reshape intrinsic gives incorrect results here.is.a.gcc.bug at gmail dot com
2023-06-20 22:18 ` [Bug fortran/100650] " damian at archaeologic dot codes
2023-06-21 9:27 ` damian at archaeologic dot codes
@ 2023-06-21 21:10 ` pault at gcc dot gnu.org
2023-06-22 21:24 ` damian at archaeologic dot codes
3 siblings, 0 replies; 5+ messages in thread
From: pault at gcc dot gnu.org @ 2023-06-21 21:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100650
Paul Thomas <pault at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2023-06-21
CC| |pault at gcc dot gnu.org
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
--- Comment #3 from Paul Thomas <pault at gcc dot gnu.org> ---
(In reply to Damian Rouson from comment #1)
> Here's a shorter reproducer:
>
> % cat reshape-array-constructor.f90
> type foo_t
> integer, allocatable :: bar(:)
> end type
>
> type(foo_t) foo(2,1)
> integer :: i, j, n(2,2,1) = reshape([-1,-1,1,1], [2,2,1])
>
> foo = reshape([([(foo_t(merge(0, 1, n(:,i,j) > 0)), i=1,2)], j=1,1)],
> [2,1])
> print *, merge(0, 1, n(:,1,1) > 0), foo(1,1)%bar
> print *, merge(0, 1, n(:,2,1) > 0), foo(2,1)%bar
> end
> % gfortran reshape-array-constructor.f90
> % ./a.out
> 1 1 -358465392 24440
> 0 0 -358465392 24440
> % gfortran --version
> GNU Fortran (Homebrew GCC 13.1.0) 13.1.0
>
> Another workaround in the above example is to make n a constant array via
>
> integer, parameter :: n(*,*,*) = reshape([-1,-1,1,1], [2,2,1])
I have played with this a bit. It's a complete mess. Breaking out the inner
array constructor to a temporary produces the same result.
I have put it on my list of TODOs. First finish associate, gather up the last
of the select type bugs and attack PDTs.
Cheers
Paul
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug fortran/100650] Passing a derived-type array constructor to the reshape intrinsic gives incorrect results
2021-05-18 12:35 [Bug fortran/100650] New: Passing a derived-type array constructor to the reshape intrinsic gives incorrect results here.is.a.gcc.bug at gmail dot com
` (2 preceding siblings ...)
2023-06-21 21:10 ` pault at gcc dot gnu.org
@ 2023-06-22 21:24 ` damian at archaeologic dot codes
3 siblings, 0 replies; 5+ messages in thread
From: damian at archaeologic dot codes @ 2023-06-22 21:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100650
--- Comment #4 from Damian Rouson <damian at archaeologic dot codes> ---
Thanks, Paul. No urgency. The workaround is simple and painless.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-06-22 21:24 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-18 12:35 [Bug fortran/100650] New: Passing a derived-type array constructor to the reshape intrinsic gives incorrect results here.is.a.gcc.bug at gmail dot com
2023-06-20 22:18 ` [Bug fortran/100650] " damian at archaeologic dot codes
2023-06-21 9:27 ` damian at archaeologic dot codes
2023-06-21 21:10 ` pault at gcc dot gnu.org
2023-06-22 21:24 ` damian at archaeologic dot codes
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).