From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3717 invoked by alias); 15 Jun 2007 14:43:13 -0000 Received: (qmail 3069 invoked by uid 48); 15 Jun 2007 14:43:03 -0000 Date: Fri, 15 Jun 2007 14:43:00 -0000 Message-ID: <20070615144303.3068.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug fortran/32140] [4.3 Regression] Miscompilation with -O1 In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "jv244 at cam dot ac dot uk" 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: 2007-06/txt/msg01203.txt.bz2 ------- Comment #10 from jv244 at cam dot ac dot uk 2007-06-15 14:43 ------- The segfault is still happening with today's code. This is the simplest case I find to trigger it. MODULE TEST CONTAINS FUNCTION s2a_3(s1) RESULT(a) CHARACTER(LEN=*), INTENT(IN) :: s1 CHARACTER(LEN=1000) :: a(3) a(1)=s1 END FUNCTION END MODULE USE TEST character(LEN=1000) :: b(3) b=s2a_3(REPEAT("1",101)) write(6,*) b(1) END The point where things segfault is the assignment a(1)=s1, and in particular the corresponding memset (which adds blanks to the rest of the string). This memset much be getting a wrong pointer to start with, according to valgrind: ==23016== Invalid write of size 1 ==23016== at 0x4A1AAF0: memset (mc_replace_strmem.c:490) ==23016== by 0x400A4D: __test_MOD_s2a_3 (test2.f90:6) ==23016== by 0x40098B: MAIN__ (test2.f90:12) ==23016== by 0x400A8B: main (fmain.c:22) ==23016== Address 0x7FF017FA8 is not stack'd, malloc'd or (recently) free'd the bug only happens if a is at the same time 1) a function result 2) an array 3) of character variables with a len known at compile time. in the dump tree original, the corresponding memset line looks like: __builtin_memset (&(*__result.0)[NON_LVALUE_EXPR + offset.1] + (char *) (int8) D.1374, 32, 1000 - (int8) D.1374); but I can't see how I could debug further.... pretty please, can somebody look into that... I'd like to be able to test all the stuff that went in since the bug was opened a few weeks ago. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32140