From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9826 invoked by alias); 10 Feb 2011 07:03:21 -0000 Received: (qmail 9816 invoked by uid 22791); 10 Feb 2011 07:03:20 -0000 X-SWARE-Spam-Status: No, hits=-2.7 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 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; Thu, 10 Feb 2011 07:03:14 +0000 From: "burnus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/47674] New: gfortran.dg/realloc_on_assign_5.f03: Segfault at run time X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: burnus at gcc dot gnu.org 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 Date: Thu, 10 Feb 2011 08:43:00 -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 X-SW-Source: 2011-02/txt/msg01283.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47674 Summary: gfortran.dg/realloc_on_assign_5.f03: Segfault at run time Product: gcc Version: 4.6.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: fortran AssignedTo: unassigned@gcc.gnu.org ReportedBy: burnus@gcc.gnu.org CC: pault@gcc.gnu.org gfortran.dg/realloc_on_assign_5.f03 segfaults here; it works if I unset the environment variable MALLOC_CHECK_. Valgrind shows: Invalid read of size 1 at 0x4C285C8: memmove (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) by 0x400B41: MAIN__ (realloc_on_assign_5.f03:15) by 0x400BF7: main (realloc_on_assign_5.f03:18) Address 0x5b524c1 is 0 bytes after a block of size 1 alloc'd at 0x4C26682: realloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) by 0x400B0C: MAIN__ (realloc_on_assign_5.f03:15) by 0x400BF7: main (realloc_on_assign_5.f03:18) Excerpt from the test: a = 'ab' ! OK a = (a(2:2)) ! seems to fail thus print '(">",a,"<")', a prints ">", STX (start of text character), "<" and a new line. Without MALLOC_CHECK_ the desired ">b<" and a new line is printed. DUMP: The first "if" does not make sense - at least in this special case - and there is the issue that "a" is also used on the RHS without using a temporary. D.1531 = .a; if (D.1531 != 0) { if (() D.1531 <= 1) { __builtin_memmove (a, &(*a)[2]{lb: 1 sz: 1}, D.1531); } else { __builtin_memcpy (a, &(*a)[2]{lb: 1 sz: 1}, 1); __builtin_memset (a + 1, 32, D.1531 + 0x0ffffffffffffffff); } }