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.

Reply via email to