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 middle-end/87489] [8/9/10/11 Regression] Spurious -Wnonnull warning Date: Mon, 01 Feb 2021 00:01:48 +0000 [thread overview] Message-ID: <bug-87489-4-oO7C7wWrAd@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-87489-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87489 --- Comment #12 from Martin Sebor <msebor at gcc dot gnu.org> --- Created attachment 50098 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50098&action=edit Patch to move -Wnonnull to pass_merge_phi. No change in GCC 11 so far. I've reduced the test case in attachment 44775 to just the essentials and copied it below. The dumps confirm that the warning in this case is issued too early, before the strlen(0B) call has been eliminated. As Jeff notes in comment #11, FRE3 is the first pass where the bad strlen call has been removed. $ cat pr87489.c && gcc -O -S -Wall -Wpedantic -fdump-tree-all pr87489.c && grep strlen * | grep 0B extern void f (const void*, int); static void g (int i, const char *s) { int j = 0; if (i) j |= 1; if (j) f (&j, 0); if (j & 1) f (s, __builtin_strlen (s)); } void h (void) { g (0, 0); } In function ‘g’, inlined from ‘h’ at ../pr87489.c:19:3: pr87489.c:14:11: warning: argument 1 null where non-null expected [-Wnonnull] 14 | f (s, __builtin_strlen (s)); | ^~~~~~~~~~~~~~~~~~~~ pr87489.c: In function ‘h’: pr87489.c:14:11: note: in a call to built-in function ‘__builtin_strlen’ pr87489.c.092t.fixup_cfg3: _6 = __builtin_strlen (0B); pr87489.c.097t.adjust_alignment: _6 = __builtin_strlen (0B); pr87489.c.098t.ccp2: _6 = __builtin_strlen (0B); pr87489.c.099t.post_ipa_warn1: _6 = __builtin_strlen (0B); pr87489.c.101t.backprop: _6 = __builtin_strlen (0B); pr87489.c.102t.phiprop: _6 = __builtin_strlen (0B); pr87489.c.103t.forwprop2: _6 = __builtin_strlen (0B); pr87489.c.104t.objsz2: _6 = __builtin_strlen (0B); pr87489.c.105t.alias: _6 = __builtin_strlen (0B); pr87489.c.106t.retslot: _6 = __builtin_strlen (0B); As an experiment, I tried running -Wnonnull later, in mergephi2 (see the attached patch titled gcc-87489.diff). That avoids the warning, passes bootstrap, and causes no testsuite regressions.
next parent reply other threads:[~2021-02-01 0:01 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top [not found] <bug-87489-4@http.gcc.gnu.org/bugzilla/> 2021-02-01 0:01 ` msebor at gcc dot gnu.org [this message] 2021-02-01 0:24 ` msebor at gcc dot gnu.org 2021-02-01 0:35 ` msebor at gcc dot gnu.org 2021-02-18 16:20 ` law at redhat dot com 2021-02-19 23:38 ` msebor at gcc dot gnu.org 2022-05-06 8:30 ` [Bug middle-end/87489] [9/10/11/12/13 " jakub at gcc dot gnu.org 2022-12-05 15:27 ` [Bug middle-end/87489] [10/11/12/13 " rguenth at gcc dot gnu.org 2023-05-08 12:21 ` [Bug middle-end/87489] [10/11/12/13/14 " rguenth 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-87489-4-oO7C7wWrAd@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).