This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/17308] nonnull attribute not as useful as it could
- From: "mark at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 11 Sep 2015 21:51:18 +0000
- Subject: [Bug middle-end/17308] nonnull attribute not as useful as it could
- Auto-submitted: auto-generated
- References: <bug-17308-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=17308
Mark Wielaard <mark at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |mark at gcc dot gnu.org
--- Comment #11 from Mark Wielaard <mark at gcc dot gnu.org> ---
(In reply to Eric Blake from comment #8)
> In other words, with a header like:
>
> void foo(void *bar) __attribute__((nonnull(1)));
>
> and a C file like:
>
> void foo(void *bar) { if (!bar) abort(); }
>
> Even if you decide that you are unable to warn about a call to foo(var)
> because the only way to analyze that var might be NULL is in the middle end
> but the warning is only emitted by the front end, AT LEAST you could have
> warned that the 'if (!bar)' conditional is assumed to be dead code based on
> the attribute placed on var.
This part has now been implemented:
https://gcc.gnu.org/ml/gcc-patches/2015-09/msg00626.html