public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/57354] New: Wrong run-time assignment of allocatable array of derived type with allocatable component
@ 2013-05-21 12:31 vladimir.fuka at gmail dot com
2013-05-21 12:36 ` [Bug fortran/57354] " vladimir.fuka at gmail dot com
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: vladimir.fuka at gmail dot com @ 2013-05-21 12:31 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57354
Bug ID: 57354
Summary: Wrong run-time assignment of allocatable array of
derived type with allocatable component
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: vladimir.fuka at gmail dot com
Created attachment 30154
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30154&action=edit
realloc.f90
source:
type t
integer,allocatable :: i
end type
type(t) :: e
type(t), allocatable :: a(:)
do i=1,100
e%i = i
if (.not.allocated(a)) then
a = [e]
else
a = [a, e]
end if
end do
print *, (a(i)%i, i=1,size(a))
end
gcc version 4.8.1 20130509 (prerelease) (GCC)
expected result: 1,2..100
actual result:
gfortran realloc.f90
./a.out
32338624 32338560 32338496 32338432 32338368 32338304
32338240 32338176 32338112 32338048 32337920 32337856
32337792 32337728 32337664 32337600 32337536 32337472
32338016 32337952 32337232 32337168 32337104 32337040
32336976 32337408 32337344 32336816 32336752 32336688
32336624 32336096 32336032 32335968 32336912 32336512
32336448 32336384 32336352 32336288 32336224 32335872
32336160 32335680 32335248 32334864 32334528 32334240
32333952 32333888 32333952 32334240 32334528 32334864
32335248 32335680 32336160 32335872 32336224 32336288
32336352 32336384 32336448 32336512 32336912 32335968
32336032 32336096 32336624 32336688 32336752 32336816
32337344 32337408 32336976 32337040 32337104 32337168
32337232 32337952 32338016 32337472 32337536 32337600
32337664 32337728 32337792 32337856 32337920 32338048
32338112 32338176 32338240 32338304 32338368 32338432
32338496 32338560 32338624 100
(the garbage differs on each run)
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/57354] Wrong run-time assignment of allocatable array of derived type with allocatable component
2013-05-21 12:31 [Bug fortran/57354] New: Wrong run-time assignment of allocatable array of derived type with allocatable component vladimir.fuka at gmail dot com
@ 2013-05-21 12:36 ` vladimir.fuka at gmail dot com
2013-11-23 14:02 ` pault at gcc dot gnu.org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: vladimir.fuka at gmail dot com @ 2013-05-21 12:36 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57354
--- Comment #1 from Vladimir Fuka <vladimir.fuka at gmail dot com> ---
valgrind ./a.out
==17600== Memcheck, a memory error detector
==17600== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
==17600== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
==17600== Command: ./a.out
==17600==
==17600== Invalid read of size 4
==17600== at 0x4012A0: MAIN__ (realloc.f90:15)
==17600== by 0x40159A: main (realloc.f90:22)
==17600== Address 0x5c4e4a0 is 0 bytes inside a block of size 4 free'd
==17600== at 0x4C2AF6C: free (in
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==17600== by 0x401181: MAIN__ (realloc.f90:15)
==17600== by 0x40159A: main (realloc.f90:22)
==17600==
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31 32 33
34 35 36 37 38 39
40 41 42 43 44 45 46
47 48 49 50 51 52 53
54 55 56 57 58 59
60 61 62 63 64 65 66
67 68 69 70 71 72 73
74 75 76 77 78 79
80 81 82 83 84 85 86
87 88 89 90 91 92 93
94 95 96 97 98 99
100
==17600==
==17600== HEAP SUMMARY:
==17600== in use at exit: 0 bytes in 0 blocks
==17600== total heap usage: 5,372 allocs, 5,372 frees, 116,676 bytes
allocated
==17600==
==17600== All heap blocks were freed -- no leaks are possible
==17600==
==17600== For counts of detected and suppressed errors, rerun with: -v
==17600== ERROR SUMMARY: 4950 errors from 1 contexts (suppressed: 2 from 2)
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/57354] Wrong run-time assignment of allocatable array of derived type with allocatable component
2013-05-21 12:31 [Bug fortran/57354] New: Wrong run-time assignment of allocatable array of derived type with allocatable component vladimir.fuka at gmail dot com
2013-05-21 12:36 ` [Bug fortran/57354] " vladimir.fuka at gmail dot com
@ 2013-11-23 14:02 ` pault at gcc dot gnu.org
2013-12-01 11:50 ` pault at gcc dot gnu.org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: pault at gcc dot gnu.org @ 2013-11-23 14:02 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57354
Paul Thomas <pault at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2013-11-23
Assignee|unassigned at gcc dot gnu.org |pault at gcc dot gnu.org
Ever confirmed|0 |1
--- Comment #3 from Paul Thomas <pault at gcc dot gnu.org> ---
Created attachment 31280
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31280&action=edit
Preliminary patch
This patch is preliminary since a temporary is produced, for each assignment,
copied to the newly reallocated lhs and then deallocated. Clearly it would be
more efficient to deallocate the lhs and then point the lhs to the temporary.
My first attempt to do this segfaulted because the temporary was still deleted,
in spite of my attempt to suppress it! I will persevere.
The test case will be along the following lines:
! { dg-do run }
!
! PR fortran/57354
!
! Contributed by Vladimir Fuka <vladimir.fuka@gmail.com>
!
type t
integer,allocatable :: i
end type
type(t) :: e
type(t), allocatable :: a(:)
integer :: chksum = 0
do i=1,3 ! Was 100 in original
e%i = i
chksum = chksum + i
if (.not.allocated(a)) then
a = [e]
else
call foo
end if
end do
if (sum ([(a(i)%i, i=1,size(a))]) .ne. chksum) call abort
contains
subroutine foo
a = [a, e]
end subroutine
end
Note that 'foo' is for diagnostic purposes - the code is separated nicely.
Cheers
Paul
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/57354] Wrong run-time assignment of allocatable array of derived type with allocatable component
2013-05-21 12:31 [Bug fortran/57354] New: Wrong run-time assignment of allocatable array of derived type with allocatable component vladimir.fuka at gmail dot com
2013-05-21 12:36 ` [Bug fortran/57354] " vladimir.fuka at gmail dot com
2013-11-23 14:02 ` pault at gcc dot gnu.org
@ 2013-12-01 11:50 ` pault at gcc dot gnu.org
2015-04-17 17:42 ` dominiq at lps dot ens.fr
2015-08-07 21:32 ` mikael at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: pault at gcc dot gnu.org @ 2013-12-01 11:50 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57354
--- Comment #5 from Paul Thomas <pault at gcc dot gnu.org> ---
Author: pault
Date: Sun Dec 1 11:50:20 2013
New Revision: 205567
URL: http://gcc.gnu.org/viewcvs?rev=205567&root=gcc&view=rev
Log:
2013-12-01 Paul Thomas <pault@gcc.gnu.org>
PR fortran/57354
* trans-array.c (gfc_conv_resolve_dependencies): For other than
SS_SECTION, do a dependency check if the lhs is liable to be
reallocated.
2013-12-01 Paul Thomas <pault@gcc.gnu.org>
PR fortran/57354
* gfortran.dg/realloc_on_assign_23.f90 : New test
Added:
trunk/gcc/testsuite/gfortran.dg/realloc_on_assign_23.f90
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/trans-array.c
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/57354] Wrong run-time assignment of allocatable array of derived type with allocatable component
2013-05-21 12:31 [Bug fortran/57354] New: Wrong run-time assignment of allocatable array of derived type with allocatable component vladimir.fuka at gmail dot com
` (2 preceding siblings ...)
2013-12-01 11:50 ` pault at gcc dot gnu.org
@ 2015-04-17 17:42 ` dominiq at lps dot ens.fr
2015-08-07 21:32 ` mikael at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: dominiq at lps dot ens.fr @ 2015-04-17 17:42 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57354
--- Comment #6 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
AFAICT this PR is fixed at 4.9.2. Any reason why it is not closed?
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/57354] Wrong run-time assignment of allocatable array of derived type with allocatable component
2013-05-21 12:31 [Bug fortran/57354] New: Wrong run-time assignment of allocatable array of derived type with allocatable component vladimir.fuka at gmail dot com
` (3 preceding siblings ...)
2015-04-17 17:42 ` dominiq at lps dot ens.fr
@ 2015-08-07 21:32 ` mikael at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: mikael at gcc dot gnu.org @ 2015-08-07 21:32 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57354
Mikael Morin <mikael at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
CC| |mikael at gcc dot gnu.org
Resolution|--- |FIXED
--- Comment #7 from Mikael Morin <mikael at gcc dot gnu.org> ---
(In reply to Dominique d'Humieres from comment #6)
> AFAICT this PR is fixed at 4.9.2. Any reason why it is not closed?
Closing.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-08-07 21:32 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-21 12:31 [Bug fortran/57354] New: Wrong run-time assignment of allocatable array of derived type with allocatable component vladimir.fuka at gmail dot com
2013-05-21 12:36 ` [Bug fortran/57354] " vladimir.fuka at gmail dot com
2013-11-23 14:02 ` pault at gcc dot gnu.org
2013-12-01 11:50 ` pault at gcc dot gnu.org
2015-04-17 17:42 ` dominiq at lps dot ens.fr
2015-08-07 21:32 ` mikael at gcc dot gnu.org
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).