Steven Bosscher wrote: > The documentation of the nonnull attribute says: > > `nonnull (ARG-INDEX, ...)' > The `nonnull' attribute specifies that some function parameters > should be non-null pointers. For instance, the declaration: > > extern void * > my_memcpy (void *dest, const void *src, size_t len) > __attribute__((nonnull (1, 2))); > > causes the compiler to check that, in calls to `my_memcpy', > arguments DEST and SRC are non-null. > > > So do we expect our users to know that they should add 1 to every > ARG-INDEX they pass? That would make this a documentation bug. Or > is this a "real" bug in G++, and should the compiler correct the > ARG-INDEX numbers so that the middle-end doesn't get confused?
I think this is a documentation bug. (Well, really, I think it's a design bug; the attribute should be applied to the parameters, rather than to the entire function type, so that users didn't have to count. In other words, it should be: void f(__attribute((nonnull)) int *); But, that's just me being wishful.) The reason I think this is a documentation bug is that (a) it's always been this way, ergo we'd be breaking backwards compatibility to change it, and (b) some of these kinds of attributes could usefully apply to the "this" pointer. -- Mark Mitchell CodeSourcery [EMAIL PROTECTED] (650) 331-3385 x713