Am Mon, 04 May 2015 18:28:49 +0200 schrieb Manuel López-Ibáñez <lopeziba...@gmail.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: > > https://gcc.gnu.org/ml/gcc/2006-04/msg00550.html > > 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: > > http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20140203/098497.html > > 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*)) { (*a)(0); } void test(void) { foo(0); bar(0); } clang warns when calling 'foo' and 'bar' with 0 argument. gcc ignores nonnull on the argument of foo and warns about calling *a. Martin