mirror of
https://github.com/gcc-mirror/gcc.git
synced 2026-05-06 23:25:24 +02:00
ca448bc5e435a2076cb3683a9be823c08a14e69e
When copying derived types with allocatable array components where the array element type also has allocatable components, the condition at line 11071 was incorrectly triggering a call to gfc_duplicate_allocatable. However, for allocatable arrays with nested allocatables (where cmp_has_alloc_comps && c->as is true), the add_when_allocated code already includes a gfc_duplicate_allocatable call (generated by the recursive structure_alloc_comps call at lines 10290-10293). This caused the outer array to be allocated twice: first by the explicit gfc_duplicate_allocatable call at line 11099, and then again by the gfc_duplicate_allocatable embedded in add_when_allocated. The first allocation was leaked when the second allocation overwrote the data pointer. PR121628 added "add_when_allocated != NULL_TREE ||" to the condition, which was redundant for scalars (already handled by !c->as) and wrong for arrays (caused double allocation). Simply removing this clause restores the correct pre-PR121628 behavior. PR fortran/123868 gcc/fortran/ChangeLog: * trans-array.cc (structure_alloc_comps): For COPY_ALLOC_COMP, remove the add_when_allocated != NULL_TREE clause that PR121628 added. This clause was redundant for scalars and caused double allocation for arrays with nested allocatable components. gcc/testsuite/ChangeLog: * gfortran.dg/array_memcpy_2.f90: Update expected memcpy count from 4 to 3, as the double allocation bug is now fixed. * gfortran.dg/pr123868.f90: New test. Signed-off-by: Christopher Albert <albert@alumni.tugraz.at>
…
…
…
…
…
…
…
…
…
…
…
…
…
…
This directory contains the GNU Compiler Collection (GCC). The GNU Compiler Collection is free software. See the files whose names start with COPYING for copying permission. The manuals, and some of the runtime libraries, are under different terms; see the individual source files for details. The directory INSTALL contains copies of the installation information as HTML and plain text. The source of this information is gcc/doc/install.texi. The installation information includes details of what is included in the GCC sources and what files GCC installs. See the file gcc/doc/gcc.texi (together with other files that it includes) for usage and porting information. An online readable version of the manual is in the files gcc/doc/gcc.info*. See http://gcc.gnu.org/bugs/ for how to report bugs usefully. Copyright years on GCC source files may be listed using range notation, e.g., 1987-2012, indicating that every year in the range, inclusive, is a copyrightable year that could otherwise be listed individually.
Description
Languages
C++
30.8%
C
30.2%
Ada
14.4%
D
6.1%
Go
5.7%
Other
12.3%