public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "msebor at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/96003] [11 Regression] Maybe a false positive for -Werror=nonnull Date: Thu, 09 Jul 2020 15:22:15 +0000 [thread overview] Message-ID: <bug-96003-4-aAOphZ7BvI@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-96003-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96003 Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 Status|UNCONFIRMED |NEW Keywords|rejects-valid | Last reconfirmed| |2020-07-09 Blocks| |95507 Summary|Maybe a false positive for |[11 Regression] Maybe a |-Werror=nonnull |false positive for | |-Werror=nonnull --- Comment #4 from Martin Sebor <msebor at gcc dot gnu.org> --- Confirmed for the test case in comment #0. It's a warning, not an error (except with -Werror if requested), so removing rejects-valid. The warning is doing what it's designed to do. The corresponding diagnostic is emitted prior to r11-1697 for the following C code: $ cat z.c && gcc -S -Wall -fdump-tree-optimized=/dev/stdout z.c __attribute__ ((nonnull)) void f (void*); void g (void **p) { f (p ? *p : 0); } z.c: In function ‘g’: z.c:5:3: warning: argument 1 null where non-null expected [-Wnonnull] 5 | f (p ? *p : 0); | ^ z.c:1:32: note: in a call to function ‘f’ declared ‘nonnull’ 1 | __attribute__ ((nonnull)) void f (void*); | ^ Unless the warning code is removed from the front end and made to rely solely on the middle end I'm not sure what the generic front end part can do to avoid triggering. Perhaps the C++ front end could wrap the 'r != 0B ? &r->D.2352 : 0B' expression somehow to briefly hide it. The warning in the test case in comment #3 looks correct to me. The function template template <typename d> void e<d>::operator++() { d()->b(); } is instantiated as a result of the calls to e<a *> begin() and e<a *> end() emitted by the for (auto i : g) loop. With d being e*, the d() expression evaluates to a null pointer, so the call is ((e*)0)->b(). Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95507 [Bug 95507] [meta-bug] bogus/missing -Wnonnull
next prev parent reply other threads:[~2020-07-09 15:22 UTC|newest] Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-06-30 11:38 [Bug tree-optimization/96003] New: " marxin at gcc dot gnu.org 2020-06-30 11:45 ` [Bug tree-optimization/96003] " jakub at gcc dot gnu.org 2020-06-30 11:54 ` marxin at gcc dot gnu.org 2020-07-09 7:04 ` slyfox at inbox dot ru 2020-07-09 15:22 ` msebor at gcc dot gnu.org [this message] 2020-07-09 15:28 ` [Bug c++/96003] [11 Regression] " msebor at gcc dot gnu.org 2020-07-09 17:40 ` slyfox at inbox dot ru 2020-07-15 6:59 ` rguenth at gcc dot gnu.org 2020-07-16 7:37 ` slyfox at inbox dot ru 2020-07-17 6:48 ` slyfox at inbox dot ru 2020-07-17 11:20 ` romain.geissler at amadeus dot com 2020-07-17 15:13 ` msebor at gcc dot gnu.org 2020-07-17 19:01 ` [Bug c++/96003] [11 Regression] spurious -Wnonnull calling a member on the result of static_cast msebor at gcc dot gnu.org 2020-07-21 19:27 ` sbergman at redhat dot com 2020-07-21 20:39 ` msebor at gcc dot gnu.org 2020-07-22 11:35 ` sbergman at redhat dot com 2020-07-30 7:36 ` marxin at gcc dot gnu.org 2020-07-30 14:30 ` msebor at gcc dot gnu.org 2020-07-31 16:29 ` cvs-commit at gcc dot gnu.org 2020-07-31 16:36 ` msebor at gcc dot gnu.org 2020-07-31 16:39 ` msebor at gcc dot gnu.org 2021-02-08 9:40 ` marxin at gcc dot gnu.org 2021-02-16 17:39 ` msebor at gcc dot gnu.org 2021-02-16 17:44 ` msebor at gcc dot gnu.org 2021-02-16 18:47 ` marxin at gcc dot gnu.org 2021-02-16 18:52 ` marxin at gcc dot gnu.org 2021-02-16 20:14 ` msebor at gcc dot gnu.org 2021-02-18 9:08 ` marxin at gcc dot gnu.org 2021-02-18 9:15 ` marxin at gcc dot gnu.org 2021-06-15 21:26 ` nyh at math dot technion.ac.il
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-96003-4-aAOphZ7BvI@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).