https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108483
--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Seems kernel has #define NULL ((void *)0), so if it is solely about allowing NULL, you could also #define ARRAY_SIZE_MAYBENULL(x) _Generic((x), void*: (BUG_ON(x), 0), default: \ sizeof(x)/sizeof(_Generic((x), void*: (x), default:*(x)))) or similar, so that uses of the macro on anything but arrays (not pointers) or NULL pointer will be diagnosed with warning or runtime error (the latter case for non-NULL void * typed pointers).