https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96021
Bug ID: 96021 Summary: missing -Wnonnull passing nullptr to a nonnull variadic lambda Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: msebor at gcc dot gnu.org Target Milestone: --- G++ issues -Wnonnull when passing nullptr to ordinary variadic functions but not for the same problem involving variadic lambdas or unspecialized templates. I believe the problem is due to the -Wnonull warning checking for arguments of pointer types and the nullptr constant not having such a type. $ cat q.C && gcc -O2 -S -Wall q.C __attribute__ ((nonnull)) void f (int, ...); void ff () { f (1, nullptr); // -Wnonnull (good) } template <class T> void g (T t) { t (1, nullptr); // missing -Wnonnull } void gg (void) { g ([](int, auto...) __attribute__ ((nonnull)) { }); } template <class T> __attribute__ ((nonnull)) void h (T); void hh () { h (nullptr); // missing -Wnonnull } q.C: In function ‘void ff()’: q.C:4:16: warning: argument 2 null where non-null expected [-Wnonnull] 4 | f (1, nullptr); // -Wnonnull (good) | ^ q.C:1:32: note: in a call to function ‘void f(int, ...)’ declared ‘nonnull’ 1 | __attribute__ ((nonnull)) void f (int, ...); | ^