public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "drepper.fsp+rhbz at gmail dot com" <gcc-bugzilla@gcc.gnu.org> 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 [thread overview] Message-ID: <bug-110654-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110654 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 <stdio.h> int main() { puts(“hello world”); return 0; } Compiling this with a recent gcc 13 or older versions leads to these error messages: u.c: In function ‘main’: u.c:3:8: error: stray ‘\342’ in program 3 | puts(<U+201C>hello world<U+201D>); | ^~~~~~~~ u.c:3:9: error: ‘hello’ undeclared (first use in this function); did you mean ‘ftello’? 3 | puts(“hello world”); | ^~~~~ | 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 ‘)’ before ‘world’ 3 | puts(“hello world”); | ~ ^~~~~~ | ) u.c:3:20: error: stray ‘\342’ in program 3 | puts(<U+201C>hello world<U+201D>); | ^~~~~~~~ The problem is the initial message about "stray ‘\342’" 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 correctly. It shows: u.c:3:8: error: extended character “ is not valid in an identifier 3 | puts(“hello world”); | ^ The C frontend should adopt the same code as the C++ frontend.
next reply other threads:[~2023-07-13 10:12 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-07-13 10:12 drepper.fsp+rhbz at gmail dot com [this message] 2023-07-13 15:41 ` [Bug c/110654] " pinskia at gcc dot gnu.org 2023-07-14 18:29 ` drepper.fsp+rhbz at gmail dot com
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-110654-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).