https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115260
Thomas Koenig <tkoenig at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |tkoenig at gcc dot gnu.org
Target Milestone|--- |13.5
Summary|Corruption of derived type |[13/14/15/16/17 Regression]
|data when array temporarys |Corruption of derived type
|of type occur |data when array temporarys
| |of type occur
Priority|P4 |P3
--- Comment #4 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
A regression
Godbolt shows that 9.4 was working: https://godbolt.org/z/Y5s57Kx86
But even with -O0, valgrind is unhappy:
ig25@bigpc:/tmp$ gfortran -g -O9 x.f90
ig25@bigpc:/tmp$ valgrind ./a.out
==402927== Memcheck, a memory error detector
==402927== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.
==402927== Using Valgrind-3.22.0 and LibVEX; rerun with -h for copyright info
==402927== Command: ./a.out
==402927==
In setfields:
1.00000000 1.00000000 1.00000000
2 2 2
After calling setfields with fieldset(2,1:4)
==402927== Invalid read of size 4
==402927== at 0x4B46F50: ??? (in
/usr/lib/x86_64-linux-gnu/libgfortran.so.5.0.0)
==402927== by 0x4B499A6: ??? (in
/usr/lib/x86_64-linux-gnu/libgfortran.so.5.0.0)
==402927== by 0x4B49E75: ??? (in
/usr/lib/x86_64-linux-gnu/libgfortran.so.5.0.0)
==402927== by 0x4B4B2C2: ??? (in
/usr/lib/x86_64-linux-gnu/libgfortran.so.5.0.0)
==402927== by 0x40180C: MAIN__ (x.f90:19)
==402927== by 0x4010FC: main (x.f90:22)
==402927== Address 0x4ecd9e0 is 0 bytes inside a block of size 12 free'd
==402927== at 0x484988F: free (in
/usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==402927== by 0x401720: MAIN__ (x.f90:17)
==402927== by 0x4010FC: main (x.f90:22)
==402927== Block was alloc'd at
==402927== at 0x4846828: malloc (in
/usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==402927== by 0x4012D9: MAIN__ (x.f90:12)
==402927== by 0x4010FC: main (x.f90:22)
==402927==
1.00000000 1.00000000 1.00000000
==402927== Invalid read of size 4
==402927== at 0x4B43B40: ??? (in
/usr/lib/x86_64-linux-gnu/libgfortran.so.5.0.0)
==402927== by 0x4B44F50: ??? (in
/usr/lib/x86_64-linux-gnu/libgfortran.so.5.0.0)
==402927== by 0x4B49F2B: ??? (in
/usr/lib/x86_64-linux-gnu/libgfortran.so.5.0.0)
==402927== by 0x4B4B2C2: ??? (in
/usr/lib/x86_64-linux-gnu/libgfortran.so.5.0.0)
==402927== by 0x40189C: MAIN__ (x.f90:20)
==402927== by 0x4010FC: main (x.f90:22)
==402927== Address 0x4ecda30 is 0 bytes inside a block of size 12 free'd
==402927== at 0x484988F: free (in
/usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==402927== by 0x40172D: MAIN__ (x.f90:17)
==402927== by 0x4010FC: main (x.f90:22)
==402927== Block was alloc'd at
==402927== at 0x4846828: malloc (in
/usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==402927== by 0x40133B: MAIN__ (x.f90:13)
==402927== by 0x4010FC: main (x.f90:22)
==402927==
2 2 2
==402927== Invalid read of size 4
==402927== at 0x4018F1: MAIN__ (x.f90:21)
==402927== by 0x4010FC: main (x.f90:22)
==402927== Address 0x4ecd9e0 is 0 bytes inside a block of size 12 free'd
==402927== at 0x484988F: free (in
/usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==402927== by 0x401720: MAIN__ (x.f90:17)
==402927== by 0x4010FC: main (x.f90:22)
==402927== Block was alloc'd at
==402927== at 0x4846828: malloc (in
/usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==402927== by 0x4012D9: MAIN__ (x.f90:12)
==402927== by 0x4010FC: main (x.f90:22)
==402927==
==402927== Invalid read of size 4
==402927== at 0x40192D: MAIN__ (x.f90:22)
==402927== by 0x4010FC: main (x.f90:22)
==402927== Address 0x4ecda30 is 0 bytes inside a block of size 12 free'd
==402927== at 0x484988F: free (in
/usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==402927== by 0x40172D: MAIN__ (x.f90:17)
==402927== by 0x4010FC: main (x.f90:22)
==402927== Block was alloc'd at
==402927== at 0x4846828: malloc (in
/usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==402927== by 0x40133B: MAIN__ (x.f90:13)
==402927== by 0x4010FC: main (x.f90:22)
==402927==
==402927== Invalid read of size 4
==402927== at 0x401939: MAIN__ (x.f90:22)
==402927== by 0x4010FC: main (x.f90:22)
==402927== Address 0x4ecda34 is 4 bytes inside a block of size 12 free'd
==402927== at 0x484988F: free (in
/usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==402927== by 0x40172D: MAIN__ (x.f90:17)
==402927== by 0x4010FC: main (x.f90:22)
==402927== Block was alloc'd at
==402927== at 0x4846828: malloc (in
/usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==402927== by 0x40133B: MAIN__ (x.f90:13)
==402927== by 0x4010FC: main (x.f90:22)
==402927==
==402927==
==402927== HEAP SUMMARY:
==402927== in use at exit: 0 bytes in 0 blocks
==402927== total heap usage: 19 allocs, 19 frees, 5,468 bytes allocated
==402927==
==402927== All heap blocks were freed -- no leaks are possible
==402927==
==402927== For lists of detected and suppressed errors, rerun with: -s
==402927== ERROR SUMMARY: 12 errors from 5 contexts (suppressed: 0 from 0)