https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80945
Bug ID: 80945
Summary: Invalid code with allocatable character array in
READ/WRITE statement
Product: gcc
Version: 8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: koenigni at gcc dot gnu.org
Target Milestone: ---
Created attachment 41446
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41446&action=edit
Test Case
Trying to compile the testcase with "-O" produces invalid code, while compiling
it without leads to a segfault.
gcc@dcm-linux:~/pr/35339> gfortran -O z5.f90
gcc@dcm-linux:~/pr/35339> ./a.out
c foo bar xyzzy
ca xyzzy
gcc@dcm-linux:~/pr/35339> gfortran z5.f90
gcc@dcm-linux:~/pr/35339> ./a.out
Program received signal SIGSEGV: Segmentation fault - invalid memory reference.
Backtrace for this error:
#0 0x7f37dee45adf in ???
#1 0x7f37dee97d15 in ???
#2 0x7f37dfb03a50 in read_default_char1
at ../../../trunk/libgfortran/io/read.c:429
#3 0x7f37dfb0809c in formatted_transfer_scalar_read
at ../../../trunk/libgfortran/io/transfer.c:1591
#4 0x7f37dfb08f2c in formatted_transfer
at ../../../trunk/libgfortran/io/transfer.c:2270
#5 0x400cb3 in ???
#6 0x400e43 in ???
#7 0x7f37dee31469 in ???
#8 0x400909 in ???
at ../sysdeps/x86_64/start.S:120
#9 0xffffffffffffffff in ???
Segmentation fault (core dumped)