From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1394 invoked by alias); 27 Jun 2014 14:33:55 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 1365 invoked by uid 48); 27 Jun 2014 14:33:51 -0000 From: "arnaud02 at users dot sourceforge.net" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/61632] New: memory corruption in Fortran RTL when writing formatted data Date: Fri, 27 Jun 2014 14:33:00 -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: 4.8.2 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: arnaud02 at users dot sourceforge.net X-Bugzilla-Status: UNCONFIRMED 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 Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-06/txt/msg02225.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61632 Bug ID: 61632 Summary: memory corruption in Fortran RTL when writing formatted data Product: gcc Version: 4.8.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: arnaud02 at users dot sourceforge.net Problem 1: using the following program: program p call ss() call ss() end program p subroutine ss CHARACTER(3), save :: ZTYP(3) DATA ZTYP /'XXX','YYY','ZZZ'/ write(*,600,IOSTAT=iosa) 0.0,ZTYP write(*,*) 'iostat=',iosa 600 FORMAT(1PE13.5,4X,A3) end subroutine ss with gfortran 4.9.0 results in a executable that crashes: 0.00000E+00 XXX iostat= 5006 0.00000E+00 XXX Program received signal SIGSEGV: Segmentation fault - invalid memory reference. A run under valgrind shows: 0.00000E+00 XXX iostat= 5006 0.00000E+00 XXX ==13768== Invalid read of size 8 ==13768== at 0x414250: _gfortrani_format_error (format.c:1147) ==13768== by 0x4047D6: require_type.part.7 (transfer.c:1158) ==13768== by 0x406718: formatted_transfer (transfer.c:1150) ==13768== by 0x404AE5: _gfortran_transfer_array (transfer.c:2170) gfortran 4.7.1 is not affected but gfortran 4.8.2 and 4.9.0 are. Problem 2: using the following program: program p call ss() call ss() end program p subroutine ss CHARACTER(3), save :: ZTYP(3) DATA ZTYP /'XXX','YYY','ZZZ'/ write(*,600) 0.0,ZTYP 600 FORMAT(1PE13.5,A3) end subroutine ss with gfortran 4.9.0 results in a executable that produces: -- 0.00000E+00XXX At line 8 of file io2.f (unit = 6, file = 'stdout') Fortran runtime error: Expected REAL for item 3 in formatted transfer, got CHARACTER (1PE13.5,A3) ^ -- The message is unclear as there are only 2 items. Moreover the expected type looks incorrect. gfortran 4.6.3, 4.7.2, 4.8.2 and 4.9.0 are affected.