https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112625
Bug ID: 112625 Summary: Segmentation fault in getter function of unlimited polymorphic object in nested container / wrapper object Product: gcc Version: 13.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: michail.stamatakis at chem dot ox.ac.uk Target Milestone: --- Created attachment 56645 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=56645&action=edit Code demonstrating the seg-fault The attached code demonstrates the problem. I have seen segmentation faults in GNU Fortran 13.1.0 and 13.2.0, but not in 12.3.0 or earlier versions. The output of the attached code for the latter two versions is shown below. Note how the getter function in tvalcont_mod seems to be executed twice in GNU Fortran 13.2.0, which also does not seem correct. $ ~/dev/gcc/12.3.0/bin/gfortran -Wall -Wextra -fsanitize=undefined test.f90 $ ./a.out tvalcont_mod::Getting value tvalcont_mod::Got value! T element type is val 3.00000000 tvalcontcont_mod::Getting value tvalcont_mod::Getting value tvalcont_mod::Got value! T tvalcontcont_mod::Got value! T element type is val 3.00000000 $ ~/dev/gcc/13.2.0/bin/gfortran -Wall -Wextra -fsanitize=undefined test.f90 $ ./a.out tvalcont_mod::Getting value tvalcont_mod::Got value! T element type is val 3.00000000 tvalcontcont_mod::Getting value tvalcont_mod::Getting value tvalcont_mod::Got value! T tvalcont_mod::Getting value tvalcont_mod::Got value! T Program received signal SIGSEGV: Segmentation fault - invalid memory reference. Backtrace for this error: #0 0x7f47caffd960 in ??? #1 0x7f47caffcac5 in ??? #2 0x7f47ca6b851f in ??? at ./signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0 #3 0x7f47ca73aaa2 in ??? at ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:513 #4 0x402443 in ??? #5 0x4044c9 in ??? #6 0x404a98 in ??? #7 0x404cfd in ??? #8 0x7f47ca69fd8f in __libc_start_call_main at ../sysdeps/nptl/libc_start_call_main.h:58 #9 0x7f47ca69fe3f in __libc_start_main_impl at ../csu/libc-start.c:392 #10 0x401184 in ??? #11 0xffffffffffffffff in ??? Segmentation fault (core dumped) $