public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/107508] New: Invalid bounds due to bogus reallocation on assignment with KIND=4 characters
@ 2022-11-02 13:13 burnus at gcc dot gnu.org
2022-11-07 10:33 ` [Bug fortran/107508] " cvs-commit at gcc dot gnu.org
2023-01-12 21:23 ` anlauf at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: burnus at gcc dot gnu.org @ 2022-11-02 13:13 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107508
Bug ID: 107508
Summary: Invalid bounds due to bogus reallocation on assignment
with KIND=4 characters
Product: gcc
Version: 13.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: burnus at gcc dot gnu.org
Target Milestone: ---
In the following code, the bounds change during the assignment
but I believe the RHS and the LHS have the same shape and length parameters.
As it works with kind=4, I assume that there is a missing '*4' in the size
calculation.
! ------------------
implicit none
character(len=:,kind=4), allocatable :: a4str(:), a4str2
allocate(character(len=7,kind=4) :: a4str(-2:3))
if (lbound(a4str,1) /= -2) error stop
if (ubound(a4str,1) /= 3) error stop
a4str = [4_"sf456aq", 4_"3dtzu24", 4_"_4fh7sm", 4_"=ff85s7", 4_"j=8af4d",
4_".,A%Fsz"]
print *, lbound(a4str), ubound(a4str) ! expected (-2:3) - actually: (1:6)
if (lbound(a4str,1) /= -2) error stop
if (ubound(a4str,1) /= 3) error stop
end
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug fortran/107508] Invalid bounds due to bogus reallocation on assignment with KIND=4 characters
2022-11-02 13:13 [Bug fortran/107508] New: Invalid bounds due to bogus reallocation on assignment with KIND=4 characters burnus at gcc dot gnu.org
@ 2022-11-07 10:33 ` cvs-commit at gcc dot gnu.org
2023-01-12 21:23 ` anlauf at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-11-07 10:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107508
--- Comment #1 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Tobias Burnus <burnus@gcc.gnu.org>:
https://gcc.gnu.org/g:071d00e0faabbd45449d2e83f207fca0f8e8ef68
commit r13-3751-g071d00e0faabbd45449d2e83f207fca0f8e8ef68
Author: Tobias Burnus <tobias@codesourcery.com>
Date: Mon Nov 7 11:32:33 2022 +0100
Fortran: Fix reallocation on assignment for kind=4 strings [PR107508]
The check whether reallocation on assignment was required did not handle
kind=4 characters correctly such that there was always a reallocation,
implying issues with pointer addresses and lower bounds. Additionally,
with all deferred strings, the old memory was not freed on reallocation.
And, finally, inside the block which was only executed if string lengths
or bounds or dynamic types changed, was a subcheck of the same, which
was effectively a no op but still confusing and at least added with -O0
extra instructions to the binary.
PR fortran/107508
gcc/fortran/ChangeLog:
* trans-array.cc (gfc_alloc_allocatable_for_assignment): Fix
string-length check, plug memory leak, and avoid generation of
effectively no-op code.
* trans-expr.cc (alloc_scalar_allocatable_for_assignment): Extend
comment; minor cleanup.
gcc/testsuite/ChangeLog:
* gfortran.dg/widechar_11.f90: New test.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug fortran/107508] Invalid bounds due to bogus reallocation on assignment with KIND=4 characters
2022-11-02 13:13 [Bug fortran/107508] New: Invalid bounds due to bogus reallocation on assignment with KIND=4 characters burnus at gcc dot gnu.org
2022-11-07 10:33 ` [Bug fortran/107508] " cvs-commit at gcc dot gnu.org
@ 2023-01-12 21:23 ` anlauf at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-01-12 21:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107508
anlauf at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |WAITING
Last reconfirmed| |2023-01-12
Ever confirmed|0 |1
--- Comment #2 from anlauf at gcc dot gnu.org ---
So fixed for gcc-13?
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-01-12 21:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-02 13:13 [Bug fortran/107508] New: Invalid bounds due to bogus reallocation on assignment with KIND=4 characters burnus at gcc dot gnu.org
2022-11-07 10:33 ` [Bug fortran/107508] " cvs-commit at gcc dot gnu.org
2023-01-12 21:23 ` anlauf 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).