public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "janschultke at googlemail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/114006] New: False positive diagnostic -Wpedantic for zero-size arrays, most vexing parse Date: Tue, 20 Feb 2024 08:46:55 +0000 [thread overview] Message-ID: <bug-114006-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114006 Bug ID: 114006 Summary: False positive diagnostic -Wpedantic for zero-size arrays, most vexing parse Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: janschultke at googlemail dot com Target Milestone: --- I got a false positive warning when compiling LLVM with g++. Here is a minimal repro: struct string { const char* data; string operator+(const char*); }; int LLVMFuzzerInitialize(int*, char***argv) { string ExitOnErr(string(*argv[0]) + ": error:"); return 0; } <source>: In function 'int LLVMFuzzerInitialize(int*, char***)': <source>:7:35: warning: ISO C++ forbids zero-size array 'argv' [-Wpedantic] 7 | string ExitOnErr(string(*argv[0]) + ": error:"); | It looks like GCC thinks that this is a most vexing parse; i.e. it thinks that argv[0] is a declarator, not a subscript operator. This cannot be correct because the next expression is + ": error" so this cannot be parsed as a function declaration. I suspect that the diagnostic for zero-size arrays is prematurely emitted, before it's actually known whether this is a function declaration or not.
next reply other threads:[~2024-02-20 8:46 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-02-20 8:46 janschultke at googlemail dot com [this message] 2024-02-20 8:55 ` [Bug c++/114006] " pinskia at gcc dot gnu.org
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-114006-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).