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).
  • [Bug c/10848... gcc-bugzilla at mkarcher dot dialup.fu-berlin.de via Gcc-bugs
    • [Bug c/... pinskia at gcc dot gnu.org via Gcc-bugs
    • [Bug c/... segher at gcc dot gnu.org via Gcc-bugs
    • [Bug c/... gcc-bugzilla at mkarcher dot dialup.fu-berlin.de via Gcc-bugs
    • [Bug c/... segher at gcc dot gnu.org via Gcc-bugs
    • [Bug c/... jakub at gcc dot gnu.org via Gcc-bugs
    • [Bug c/... jakub at gcc dot gnu.org via Gcc-bugs
    • [Bug c/... jakub at gcc dot gnu.org via Gcc-bugs

Reply via email to