[Bug fortran/96909] New: ICE with nested polymorphic allocatable component

2020-09-02 Thread dlhough at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96909

Bug ID: 96909
   Summary: ICE with nested polymorphic allocatable component
   Product: gcc
   Version: 10.2.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: fortran
  Assignee: unassigned at gcc dot gnu.org
  Reporter: dlhough at gmail dot com
  Target Milestone: ---

The following code compiles successfully if the "nest" component is declared as
type() rather than class().


module Test_m
   implicit none
   private

   type, public :: Test_t
  class(Test_t), allocatable :: nest 
   end type

end module



Command line output:

gfortran -v -save-temps -Wall -Wextra -c ../../test/TestAllocatableCopy.f90 
Using built-in specs.
COLLECT_GCC=gfortran
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure --prefix=/usr --libdir=/usr/lib
--libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info
--with-bugurl=https://bugs.archlinux.org/
--enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++,d --with-isl
--with-linker-hash-style=gnu --with-system-zlib --enable-__cxa_atexit
--enable-cet=auto --enable-checking=release --enable-clocale=gnu
--enable-default-pie --enable-default-ssp --enable-gnu-indirect-function
--enable-gnu-unique-object --enable-install-libiberty --enable-linker-build-id
--enable-lto --enable-multilib --enable-plugin --enable-shared
--enable-threads=posix --disable-libssp --disable-libstdcxx-pch
--disable-libunwind-exceptions --disable-werror
gdc_include_dir=/usr/include/dlang/gdc
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 10.2.0 (GCC) 
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-Wall' '-Wextra' '-c' '-mtune=generic'
'-march=x86-64'
 /usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/f951
../../test/TestAllocatableCopy.f90 -quiet -dumpbase TestAllocatableCopy.f90
-mtune=generic -march=x86-64 -auxbase TestAllocatableCopy -Wall -Wextra
-version -fintrinsic-modules-path
/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/finclude
-fpre-include=/usr/include/finclude/math-vector-fortran.h -o
TestAllocatableCopy.s
GNU Fortran (GCC) version 10.2.0 (x86_64-pc-linux-gnu)
compiled by GNU C version 10.2.0, GMP version 6.2.0, MPFR version
4.1.0, MPC version 1.1.0, isl version isl-0.21-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU Fortran2008 (GCC) version 10.2.0 (x86_64-pc-linux-gnu)
compiled by GNU C version 10.2.0, GMP version 6.2.0, MPFR version
4.1.0, MPC version 1.1.0, isl version isl-0.21-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
gfortran: internal compiler error: Segmentation fault signal terminated program
f951
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://bugs.archlinux.org/> for instructions.

[Bug fortran/96910] New: intrinsic assignment does not duplicate allocatable component of nested derived type

2020-09-02 Thread dlhough at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96910

Bug ID: 96910
   Summary: intrinsic assignment does not duplicate allocatable
component of nested derived type
   Product: gcc
   Version: 10.2.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: fortran
  Assignee: unassigned at gcc dot gnu.org
  Reporter: dlhough at gmail dot com
  Target Milestone: ---

In the following code, I would expect a new allocation to be made for copy%nest
in the assignment copy=original in the same fashion as a new allocation is
created for copy%child. However, copy%nest and original%nest are at the same
address following the assignment as demonstrated by the print statements.


module TestAllocatableCopy_m
   implicit none
   private

   type, public :: Child_t
   end type

   type, public :: Test_t
  type(Test_t), allocatable :: nest 
  type(Child_t), allocatable :: child
   end type

end module

program TestAllocatableCopy
   use TestAllocatableCopy_m
   implicit none

   type(Test_t), target :: original
   type(Test_t), target :: copy
   class(Test_t), pointer :: nestPtr
   class(Child_t), pointer :: childPtr

   allocate(original%nest)
   allocate(original%child)

   nestPtr => original%nest
   childPtr => original%child

   copy = original

   ! prints "Child: F" with GCC 10.2
   print *, "Child:", associated(childPtr, copy%child)

   ! prints "Nest: T" with GCC 10.2
   ! expected: "Nest: F"
   print *, "Nest:", associated(nestPtr, copy%nest)

end program


Compilation command:
gfortran -v -save-temps -Wall -Wextra  ../../test/TestAllocatableCopy.f90 
Driving: gfortran -v -save-temps -Wall -Wextra
../../test/TestAllocatableCopy.f90 -l gfortran -l m -shared-libgcc
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure --prefix=/usr --libdir=/usr/lib
--libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info
--with-bugurl=https://bugs.archlinux.org/
--enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++,d --with-isl
--with-linker-hash-style=gnu --with-system-zlib --enable-__cxa_atexit
--enable-cet=auto --enable-checking=release --enable-clocale=gnu
--enable-default-pie --enable-default-ssp --enable-gnu-indirect-function
--enable-gnu-unique-object --enable-install-libiberty --enable-linker-build-id
--enable-lto --enable-multilib --enable-plugin --enable-shared
--enable-threads=posix --disable-libssp --disable-libstdcxx-pch
--disable-libunwind-exceptions --disable-werror
gdc_include_dir=/usr/include/dlang/gdc
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 10.2.0 (GCC) 
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-Wall' '-Wextra' '-shared-libgcc'
'-mtune=generic' '-march=x86-64'
 /usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/f951
../../test/TestAllocatableCopy.f90 -quiet -dumpbase TestAllocatableCopy.f90
-mtune=generic -march=x86-64 -auxbase TestAllocatableCopy -Wall -Wextra
-version -fintrinsic-modules-path
/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/finclude
-fpre-include=/usr/include/finclude/math-vector-fortran.h -o
TestAllocatableCopy.s
GNU Fortran (GCC) version 10.2.0 (x86_64-pc-linux-gnu)
compiled by GNU C version 10.2.0, GMP version 6.2.0, MPFR version
4.1.0, MPC version 1.1.0, isl version isl-0.21-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU Fortran2008 (GCC) version 10.2.0 (x86_64-pc-linux-gnu)
compiled by GNU C version 10.2.0, GMP version 6.2.0, MPFR version
4.1.0, MPC version 1.1.0, isl version isl-0.21-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-Wall' '-Wextra' '-shared-libgcc'
'-mtune=generic' '-march=x86-64'
 as -v --64 -o TestAllocatableCopy.o TestAllocatableCopy.s
GNU assembler version 2.35 (x86_64-pc-linux-gnu) using BFD version (GNU
Binutils) 2.35
Reading specs from
/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../lib/libgfortran.spec
rename spec lib to liborig
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-Wall' '-Wextra' '-shared-libgcc'
'-mtune=generic' '-march=x86-64'
COMPILER_PATH=/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/:/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/:/usr/lib/gcc/x86_64-pc-linux-gnu/:/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/:/usr/lib/gcc/x86_64-pc-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/:/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../lib/:/lib/../lib/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-sa

[Bug fortran/97123] double free detected in tcache 2 with recursive allocatable type

2020-09-28 Thread dlhough at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97123

Luke Hough  changed:

   What|Removed |Added

 CC||dlhough at gmail dot com

--- Comment #2 from Luke Hough  ---
This is likely related to bug #96910.

The intrinsic assignment operator does not duplicate the allocated
subcomponents during assignment for recursive types. The `top_level =
init_recursive()` creates a temporary storage for the RHS before assigning to
the LHS. After assignment, the temporary RHS is deallocated. Since the
subcomponent is not properly duplicated during the assignment, this leads to a
double free.