From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 77065 invoked by alias); 16 Oct 2015 18:03:12 -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 77012 invoked by uid 48); 16 Oct 2015 18:03:06 -0000 From: "kargl at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/67987] ICE on declaring and initializing character with negative len Date: Fri, 16 Oct 2015 18:03: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-Version: 5.2.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: kargl at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: kargl at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: 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: 2015-10/txt/msg01328.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67987 --- Comment #2 from kargl at gcc dot gnu.org --- (In reply to kargl from comment #1) > I have a patch that I'm testing. For the code in the > intial report I get > > troutmask:sgk[238] gfc6 -c g6.f90 > g6.f90:2:15: > > character(-8) :: c = ' ' > 1 > Error: LEN at (1) must be greater than or equal to 0 Seems the patch causes a regression for char_length_2.f90. This test came in with the fix for PR fortran/31250, where negative length parameters are silently set to 0. The fix for this regression is in resolve.c. Unfortnately, this fix then exposes an issue with substring referecences. For "string"(1:-1), this should result in a 0 length string, but gfortran is setting the length to -1 in gfc_resolve_substring_charlen.