This is the mail archive of the
mailing list for the GCC project.
Re: Couldn't `function(arg[static 3])` imply nonnull and array size in C?
- From: Martin Uecker <uecker at eecs dot berkeley dot edu>
- To: Manuel LÃpez-IbÃÃez <lopezibanez at gmail dot com>
- Cc: GCC Development <gcc at gcc dot gnu dot org>
- Date: Thu, 7 May 2015 10:51:44 -0700
- Subject: Re: Couldn't `function(arg[static 3])` imply nonnull and array size in C?
- Authentication-results: sourceware.org; auth=none
- References: <CAEcf3Nzxt=uATHYdYu+aLBoKaB8Wyy=AztF=ZXn-atKpKhVU3Q at mail dot gmail dot com> <20150503224039 dot 28ab0404 at lemur> <55479E41 dot 2070108 at gmail dot com>
Am Mon, 04 May 2015 18:28:49 +0200
schrieb Manuel LÃpez-IbÃÃez <email@example.com>:
> On 04/05/15 07:40, Martin Uecker wrote:
> > BTW: Why is 'nonnull' a function attribute and not something
> > which can be attached to pointer types?
> I think this is something wanted for a long time:
> but nobody has implemented it yet. Perhaps there was some technical hurdle in
> the past, probably long gone.
> Clang has implemented this variation already sometime ago:
> so there is a precedent.
Interestingly, this leads to an incompatibility between gcc and
clang. Consider this:
void foo(__attribute__((nonnull)) int *a)
void bar(__attribute__((nonnull)) int (*a)(int*))
clang warns when calling 'foo' and 'bar' with 0 argument.
gcc ignores nonnull on the argument of foo and warns about