public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/56201] New: Realloc on assignment: Wrong code when assigning a zero-sized array
@ 2013-02-04 12:19 burnus at gcc dot gnu.org
2014-01-07 13:59 ` [Bug fortran/56201] " dominiq at lps dot ens.fr
2014-03-15 12:12 ` burnus at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: burnus at gcc dot gnu.org @ 2013-02-04 12:19 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56201
Bug #: 56201
Summary: Realloc on assignment: Wrong code when assigning a
zero-sized array
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: burnus@gcc.gnu.org
CC: pault@gcc.gnu.org
Reported by Vladimír Fuka at
https://groups.google.com/d/topic/comp.lang.fortran/Qhrw1XU7U8o/discussion
Assigning a zero-sized array to an *unallocated* allocatable works;
re-assigning to a zero-sized array works as well. But:
Assigning a zero-sized array to an allocated non-zero-size array wrongly
deallocates the array.
real, allocatable :: r(:)
r = [real :: ] ! Zero-sized array
print *, allocated(r) ! OK: Allocated
print *, size(r)
if (.not.allocated(r) .or. size(r) /= 0) call abort()
r = [real :: ] ! Zero-sized array
print *, allocated(r) ! OK: Allocated
print *, size(r)
deallocate(r) ! REALLOCATE to nonzero sized
allocate(r(5)) !
r = [real :: ] ! <<<<<<<<< Zero-sized array
print *, allocated(r) ! <<<<<<<<< ERROR: Not allocated
print *, size(r)
if (.not.allocated(r) .or. size(r) /= 0) call abort()
end
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug fortran/56201] Realloc on assignment: Wrong code when assigning a zero-sized array
2013-02-04 12:19 [Bug fortran/56201] New: Realloc on assignment: Wrong code when assigning a zero-sized array burnus at gcc dot gnu.org
@ 2014-01-07 13:59 ` dominiq at lps dot ens.fr
2014-03-15 12:12 ` burnus at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: dominiq at lps dot ens.fr @ 2014-01-07 13:59 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56201
Dominique d'Humieres <dominiq at lps dot ens.fr> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |WAITING
Last reconfirmed| |2014-01-07
Ever confirmed|0 |1
--- Comment #1 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
WORKSFORME on *-*darwin* from 4.6.4 up to trunk (no error with valgrind of
-fsanitize=address).
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug fortran/56201] Realloc on assignment: Wrong code when assigning a zero-sized array
2013-02-04 12:19 [Bug fortran/56201] New: Realloc on assignment: Wrong code when assigning a zero-sized array burnus at gcc dot gnu.org
2014-01-07 13:59 ` [Bug fortran/56201] " dominiq at lps dot ens.fr
@ 2014-03-15 12:12 ` burnus at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: burnus at gcc dot gnu.org @ 2014-03-15 12:12 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56201
Tobias Burnus <burnus at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|WAITING |RESOLVED
Resolution|--- |WORKSFORME
--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> ---
Seems to be also okay looking at the dump:
if ((real(kind=4)[0:] * restrict) r.data == 0B)
r.data = (void * restrict) __builtin_malloc (1);
else if (D.2390)
r.data = (void * restrict) __builtin_realloc ((void *) r.data,
1);
This closing as WORKSFORME
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-03-15 12:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-04 12:19 [Bug fortran/56201] New: Realloc on assignment: Wrong code when assigning a zero-sized array burnus at gcc dot gnu.org
2014-01-07 13:59 ` [Bug fortran/56201] " dominiq at lps dot ens.fr
2014-03-15 12:12 ` burnus 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).