[Bug c++/79961] Should diagnose when '__nonnull__' attribute is applied to implicit this argument
palves at redhat dot com
gcc-bugzilla@gcc.gnu.org
Wed Mar 8 19:10:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79961
--- Comment #5 from Pedro Alves <palves at redhat dot com> ---
> We certainly should allow __attribute__((nonnull)) on methods, even when that > includes nonnull (implicit) also for this.
Yes, agreed, with implicit nonnull with no specified argument.
For the case of specifying an argument number with nonnull(N), I don't find the
error weird at all, because "this" can never be NULL. Even without the
attribute, the compiler is already free to assume that. Calling a method via a
null pointer is undefined behavior. So __attribute__((nonnull(1))) on a
non-static method is _always_ a bug.
More information about the Gcc-bugs
mailing list