public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/87489] [10/11/12/13 Regression] Spurious -Wnonnull warning
Date: Mon, 05 Dec 2022 15:27:05 +0000	[thread overview]
Message-ID: <bug-87489-4-vW4dxADThc@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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|2020-06-03 00:00:00         |2022-12-5

--- Comment #19 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Andrew Church from comment #5)
> Simpler testcase (based on the testcase in bug 87041):
> 
> extern int strcmp(const char *a, const char *b) __attribute__((nonnull(1,
> 2)));
> int foo(void) {
>     const char * const s = 0;
>     if (s)
>         return strcmp(s, "");
>     else
>         return 2;
> }
> 
> foo.c: In function 'foo':
> foo.c:5:16: warning: null argument where non-null required (argument 1)
> [-Wnonnull]
>          return strcmp(s, "");
>                 ^~~~~~

This one warns in the frontend where we substituted the const char * const s
initializer:

#0  warning_at (location=258981, opt=697, gmsgid=0x2fe4c10 "argument %u null
where non-null expected")
    at /home/rguenther/src/trunk/gcc/diagnostic.cc:1876
#1  0x0000000000d2bf3b in check_nonnull_arg (ctx=0x7fffffffc440,
param=<integer_cst 0x7ffff641b9a8>, param_num=1)
    at /home/rguenther/src/trunk/gcc/c-family/c-common.cc:5822
#2  0x0000000000d2d22a in check_function_arguments_recurse (callback=0xd2bcdc
<check_nonnull_arg(void*, tree, unsigned long)>, 
    ctx=0x7fffffffc440, param=<integer_cst 0x7ffff641b9a8>, param_num=1,
opt=OPT_Wnonnull)
    at /home/rguenther/src/trunk/gcc/c-family/c-common.cc:6195
#3  0x0000000000d2b4c9 in check_function_nonnull (ctx=..., nargs=2,
argarray=0x7ffff640bc60)
    at /home/rguenther/src/trunk/gcc/c-family/c-common.cc:5621
#4  0x0000000000d2cc9b in check_function_arguments (loc=258981,
fndecl=<function_decl 0x7ffff638a600 strcmp>, 
    fntype=<function_type 0x7ffff6417498>, nargs=2, argarray=0x7ffff640bc60,
arglocs=0x7fffffffc4a0)
    at /home/rguenther/src/trunk/gcc/c-family/c-common.cc:6071
#5  0x0000000000c3fad6 in build_function_call_vec (loc=258981, arg_loc=...,
function=<addr_expr 0x7ffff641d3a0>, 
    params=0x7ffff640bc58 = {...}, origtypes=0x7ffff640be60 = {...},
orig_fundecl=<function_decl 0x7ffff638a600 strcmp>)
    at /home/rguenther/src/trunk/gcc/c/c-typeck.cc:3319
#6  0x0000000000c40294 in c_build_function_call_vec (loc=258981, arg_loc=...,
function=<function_decl 0x7ffff638a600 strcmp>, 
    params=0x7ffff640bc58 = {...}, origtypes=0x7ffff640be60 = {...}) at
/home/rguenther/src/trunk/gcc/c/c-typeck.cc:3387
#7  0x0000000000ca02bb in c_parser_postfix_expression_after_primary
(parser=0x7ffff6275c60, expr_loc=258981, expr=...)
    at /home/rguenther/src/trunk/gcc/c/c-parser.cc:11245


Re-confirmed for the other cases.

  parent reply	other threads:[~2022-12-05 15:27 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 ` [Bug middle-end/87489] [8/9/10/11 " msebor at gcc dot gnu.org
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 ` rguenth at gcc dot gnu.org [this message]
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-vW4dxADThc@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: link
Be 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).