From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 6CDBD385801D; Mon, 22 Mar 2021 14:02:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6CDBD385801D From: "phil1691 at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/99711] New: Crash when reading an allocated character array in namelist Date: Mon, 22 Mar 2021 14:02:36 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 10.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: phil1691 at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 22 Mar 2021 14:02:36 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99711 Bug ID: 99711 Summary: Crash when reading an allocated character array in namelist Product: gcc Version: 10.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: phil1691 at gmail dot com Target Milestone: --- The following code crashes with a segmentation fault (gcc 10.2.0): > cat alloc_nml.f90=20 program allocnml implicit none character(len=3D:), dimension(:), allocatable :: cbulist_ru integer :: iluseg namelist /nam_bu_ru/ cbulist_ru allocate( character(len=3D10) :: cbulist_ru(5) ) open(newunit=3Diluseg, file=3D'list.nml', status=3D'old', & action=3D'read', form=3D'formatted', access=3D'sequential') read(unit=3Diluseg, nml=3Dnam_bu_ru) print *, cbulist_ru close(unit=3Diluseg) end program allocnml With the following namelist file: > cat list.nml &NAM_BU_RU CBULIST_RU(1) =3D 'PRES' CBULIST_RU(2) =3D 'NEST' CBULIST_RU(3) =3D 'HTURB' CBULIST_RU(4) =3D 'VTURB' / Compilation: > gfortran -g alloc_nml.f90 Execution: > ./a.out=20 Program received signal SIGSEGV: Segmentation fault - invalid memory refere= nce. Backtrace for this error: #0 0x146bdba3349f in ??? #1 0x146bdbb57d7a in ??? #2 0x146bdc79df4b in nml_read_obj at ../../../gcc-10.2.0-srcdir/libgfortran/io/list_read.c:3142 #3 0x146bdc79ee8a in nml_get_obj_data at ../../../gcc-10.2.0-srcdir/libgfortran/io/list_read.c:3512 #4 0x146bdc7a78b7 in finalize_transfer at ../../../gcc-10.2.0-srcdir/libgfortran/io/transfer.c:4128 #5 0x400d48 in allocnml at /home/waup/F90/bug_gcc/character_allocatable_namelist/alloc_nml.f90:14 #6 0x400e20 in main at /home/waup/F90/bug_gcc/character_allocatable_namelist/alloc_nml.f90:19 Erreur de segmentation (core dumped)=