This is the mail archive of the
gcc@gcc.gnu.org
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: Campbell Barton <ideasman42 at gmail dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Sun, 3 May 2015 22:40:39 -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>
Campbell Barton <ideasman42@gmail.com>:
...
> Given the simple function:
>
> void print_v3(float v[static 3])
> {
> printf("%f %f %f\n", v[0], v[1], v[2]);
> }
>
> Calling `foo(NULL);` or `{ float v[2]; foo(v); }` should be able to
> cause a warning, it would be useful since this is a farily
Yes. I want this too! But somebody needs to implement this...
BTW: Why is 'nonnull' a function attribute and not something
which can be attached to pointer types?