https://gcc.gnu.org/bugzilla/show_bug.cgi?id=50584

nsz at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nsz at gcc dot gnu.org

--- Comment #12 from nsz at gcc dot gnu.org ---
(1) consider a simplified example from bug 17308

  __attribute__((nonnull(1)))
  void foo(char *bar) { if (!bar) __builtin_abort(); }

with gcc -O2 -fno-asynchronous-unwind-tables -fomit-frame-pointer -std=c99
-Wall
i get warnings:

  a.c: In function 'foo':
  a.c:2:27: warning: nonnull argument 'bar' compared to NULL [-Wnonnull]
   void foo(char *bar) { if (!bar) __builtin_abort(); }
                           ^
and asm code:

  foo:
        rep ret

(2) however code with similar semantics:

  void foo(char bar[static 1]) { if (!bar) __builtin_abort(); }

gives no warnings and the generated asm is

  foo:
        testq   %rdi, %rdi
        je      .L7
        rep ret
  .L7:
        pushq   %rax
        call    abort

the code in (2) should at least imply nonnull argument, since this is
the idiomatic nonnull annotation in c since c99.

(unfortunately it does not work for void* arguments, otherwise i think
it is useful for static analysis, but it won't be used in practice
unless compilers make use of it.)

Reply via email to