As I was writing a unit test, I stumbled upon some odd behavior from glibc
, regarding "%p"
and the NULL
pointer.
If I have a line such as printf("NULL pointer is %p\n", NULL);
, then I see NULL pointer is (nil)
printed to the screen, as I expected.
If I instead use the wide-character version: wprintf(L"NULL pointer is %p\n", NULL);
, then it prints out NULL pointer is (
, and stops at the opening parenthesis. If I print a non-NULL
pointer, it prints that pointer, both normal and wide-character versions. Is this a known bug of glibc
, or am I just missing something?
NB: I realize that the C standard says that pointers with %p
are converted in an implementation-defined manner; it just seems unusual to just print (
for a NULL
pointer.