From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C0972389683B; Mon, 12 Apr 2021 10:11:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C0972389683B From: "bernd.edlinger at hotmail dot de" To: gcc-bugs@gcc.gnu.org Subject: [Bug preprocessor/99446] [11 Regression] ICE in linemap_position_for_loc_and_offset, at libcpp/line-map.c:1005 since r11-6325 Date: Mon, 12 Apr 2021 10:11:55 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: preprocessor X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: ice-on-valid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: bernd.edlinger at hotmail dot de X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 11.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Apr 2021 10:11:55 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99446 Bernd Edlinger changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bernd.edlinger at hotmail = dot de --- Comment #7 from Bernd Edlinger --- Hmm, I don't fully understand what's the reason why the assertion fires here. ... but what's apparently wrong here, is the location before the EOF is in a different file. While it was intended to show the line above the end-of-file, it was likely not intended to show the last token in a different include file? So something like that fixes the test case: diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 59adac4..99026f4 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -668,7 +668,8 @@ cp_lexer_new_main (void) + lexer->buffer->length () - 1; - if (lexer->buffer->length () !=3D 1) + if (lexer->buffer->length () !=3D 1 + && LOCATION_FILE (tok[-1].location) =3D=3D LOCATION_FILE(tok[0].loca= tion)) { /* Set the EOF token's location to be the just after the previous token's range. That way 'at-eof' diagnostics point at something=