From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23103 invoked by alias); 2 Apr 2012 15:22:15 -0000 Received: (qmail 23090 invoked by uid 22791); 2 Apr 2012 15:22:13 -0000 X-SWARE-Spam-Status: No, hits=-3.0 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,TW_BG X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 02 Apr 2012 15:22:00 +0000 From: "arnaud02 at users dot sourceforge.net" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/52835] New: Incorrect code generated by gfortran 4.7.0 Date: Mon, 02 Apr 2012 15:22: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-Keywords: X-Bugzilla-Severity: major 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-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 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 X-SW-Source: 2012-04/txt/msg00107.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52835 Bug #: 52835 Summary: Incorrect code generated by gfortran 4.7.0 Classification: Unclassified Product: gcc Version: 4.7.0 Status: UNCONFIRMED Severity: major Priority: P3 Component: fortran AssignedTo: unassigned@gcc.gnu.org ReportedBy: arnaud02@users.sourceforge.net >uname -sm Linux x86_64 >cat qq.f SUBROUTINE QQ2( ISU, ZSPM, RSV, MS ) INTEGER :: ISU(MS) CHARACTER(8) :: ZSPM(MS) REAL :: RSV(MS) DO IS=1,MS ISU(IS)=0 ZSPM(IS)=' ' RSV(IS) =0.0 ENDDO END subroutine qq2 SUBROUTINE QQ() INTEGER, ALLOCATABLE :: ISU(:) CHARACTER(8), ALLOCATABLE :: ZSPM(:) REAL, ALLOCATABLE :: RSV(:) ALLOCATE( RSV(3) ) ALLOCATE( ISU(3) ) ALLOCATE( ZSPM(3) ) CALL QQ2( ISU, ZSPM, RSV, 3 ) write(*,*) '-->',zspm(1) END subroutine qq program p1 call qq() end program p1 >gfortran470 -O3 -g qq.f -static-libgfortran ; valgrind --track-origins=yes ./a.out ==18017== Memcheck, a memory error detector ==18017== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al. ==18017== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info ==18017== Command: ./a.out ==18017== ==18017== Syscall param write(buf) points to uninitialised byte(s) ==18017== at 0x3541CC4150: __write_nocancel (in /lib64/libc-2.5.so) ==18017== by 0x40981C: raw_write (unix.c:308) ==18017== by 0x40F4FE: _gfortrani_fbuf_flush (unix.h:56) ==18017== by 0x405416: _gfortrani_next_record (transfer.c:3397) ==18017== by 0x405CF8: _gfortran_st_write_done (transfer.c:3592) ==18017== by 0x401C5B: qq_ (qq.f:22) ==18017== by 0x401CFC: main (qq.f:26) ==18017== Address 0x4c2fb44 is 4 bytes inside a block of size 512 alloc'd ==18017== at 0x4A0776F: malloc (vg_replace_malloc.c:263) ==18017== by 0x4037B8: _gfortrani_get_mem (memory.c:43) ==18017== by 0x40F38A: _gfortrani_fbuf_init (fbuf.c:43) ==18017== by 0x408F89: _gfortrani_init_units (unit.c:585) ==18017== by 0x403747: init (main.c:226) ==18017== by 0x4196F5: ??? (in /tmp/arnaud/a.out) ==18017== by 0x401612: ??? (in /tmp/arnaud/a.out) ==18017== by 0x9CA212C00000000: ??? ==18017== by 0x419676: __libc_csu_init (in /tmp/arnaud/a.out) ==18017== by 0x3541C1D84D: (below main) (in /lib64/libc-2.5.so) ==18017== Uninitialised value was created by a heap allocation ==18017== at 0x4A0776F: malloc (vg_replace_malloc.c:263) ==18017== by 0x401BE0: qq_ (qq.f:20) ==18017== by 0x401CFC: main (qq.f:26) ==18017== --> ==18017== ==18017== HEAP SUMMARY: ==18017== in use at exit: 0 bytes in 0 blocks ==18017== total heap usage: 20 allocs, 20 frees, 3,878 bytes allocated ==18017== ==18017== All heap blocks were freed -- no leaks are possible ==18017== ==18017== For counts of detected and suppressed errors, rerun with: -v ==18017== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 4 from 4) The test case above demonstrates the problem observed on a large production system. In qq2, zspm is not set properly to " " as shown by valgrind. This is taking place only when compiled with "-O3". This is a regression with respect to gfortran 4.6.2.