From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E086D3858C1F; Thu, 13 Jul 2023 10:12:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E086D3858C1F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1689243137; bh=bqJsS6AqtrogIXxgqQ9QKk6qZBf0O/LAyiS1c/cnsxI=; h=From:To:Subject:Date:From; b=SHj+b598Il0kJvoQcrdTnM+HMziJVkYp1AOPhu8EvwTTc7drNAveHBJwbCwq/aB13 TejpWoaycLjq3zxQAJ+s6idLeyaJWQwXqqiFg4mvnUzQVe+9pV3WLno3AzzbgFjwzw HCbeeA7OpNJGOemxddX6+HUl37PKS47eLQHq7P7w= From: "drepper.fsp+rhbz at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/110654] New: inconsistent error message in presence of unexpected encoded characters Date: Thu, 13 Jul 2023 10:12:16 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: drepper.fsp+rhbz at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D110654 Bug ID: 110654 Summary: inconsistent error message in presence of unexpected encoded characters Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: drepper.fsp+rhbz at gmail dot com Target Milestone: --- Take this code which in a similar form was taken from a text document where= the smart quote handling used the U201c and U201d characters instead of simple ASCII double quotes. Note, this text should be encoded in UTF-8 and the environment of the compiler must use UTF-8 as well. #include int main() { puts(=E2=80=9Chello world=E2=80=9D); return 0; } Compiling this with a recent gcc 13 or older versions leads to these error messages: u.c: In function =E2=80=98main=E2=80=99: u.c:3:8: error: stray =E2=80=98\342=E2=80=99 in program 3 | puts(hello world); | ^~~~~~~~ u.c:3:9: error: =E2=80=98hello=E2=80=99 undeclared (first use in this funct= ion); did you mean =E2=80=98ftello=E2=80=99? 3 | puts(=E2=80=9Chello world=E2=80=9D); | ^~~~~ | ftello u.c:3:9: note: each undeclared identifier is reported only once for each function it appears in u.c:3:14: error: expected =E2=80=98)=E2=80=99 before =E2=80=98world=E2=80=99 3 | puts(=E2=80=9Chello world=E2=80=9D); | ~ ^~~~~~ | ) u.c:3:20: error: stray =E2=80=98\342=E2=80=99 in program 3 | puts(hello world); | ^~~~~~~~ The problem is the initial message about "stray =E2=80=98\342=E2=80=99" and= the notation used in the context line. In the later the byte is correctly recognized as being part on an UTF-8 character. Note that this is in contrast to the C++ frontend which handles this correc= tly. It shows: u.c:3:8: error: extended character =E2=80=9C is not valid in an identifier 3 | puts(=E2=80=9Chello world=E2=80=9D); | ^ The C frontend should adopt the same code as the C++ frontend.=