From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17912 invoked by alias); 10 May 2012 10:35:52 -0000 Received: (qmail 17814 invoked by uid 22791); 10 May 2012 10:35:50 -0000 X-SWARE-Spam-Status: No, hits=-4.3 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,KHOP_THREADED 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 May 2012 10:35:38 +0000 From: "burnus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/53296] Segfault on non-constant character array constructor containing kind spec Date: Thu, 10 May 2012 11:29:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed 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: In-Reply-To: References: 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-05/txt/msg01088.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53296 --- Comment #2 from Tobias Burnus 2012-05-10 10:35:22 UTC --- Simplified program. * As is, it prints 128 * Without "txt", it prints 5 and segfaults * Without character(len=128) :: "txt", it prints 5 and works Thus, the extension to 128 characters does not properly work in the case of having no character literal. That matches what is in the code: character(kind=1) A.16[2][1:5]; vs. character(kind=1) A.15[3][1:128]; I have not looked through the source code, but the first place, where constructors string lengths are handled is array.c's gfc_resolve_character_array_constructor. I don't quickly see whether it does so correctly or not. If it does, the failure must be later. It might be that in that function, the "txt" is correctly extended and padded to len=128 - and that then everything is later handled correctly because the first element has the right size? program charArrErr implicit none call rou([character(len=128) :: "txt", uCase("abcde"),uCase("ghij_")]) contains subroutine rou(arr) implicit none character(*),intent(in) :: arr(:) print *, len(arr) end subroutine function uCase(str) implicit none character(*), intent(in) :: str character(len(str)) :: uCase uCase=str end function uCase end program charArrErr