NULL to intptr_t or uintptr_tAuthors: Jay Ghiron
Date: 2026-05-06
Submitted against: C23
Status: Open
Before C23, the following program was always valid if intptr_t was
defined:
#include<stddef.h>
#include<stdint.h>
int main(){
(intptr_t)NULL;
}
However, NULL is now allowed to be defined as nullptr which cannot
be cast to an integer type. It seems unnecessary to forbid this, and
C++ allows using nullptr in place of (void*)0 in pointer to
integer conversions.
Modify C23 6.5.5 paragraph 4:
The type
nullptr_tshall not be converted to any floating typeother than.void,boolor a pointer type
Note: The text seems to currently forbid (nullptr_t)nullptr despite
the next sentence intending to allow it.
Replace C23 6.3.3.4:
A value of type
nullptr_tcan be converted to an integer type, the result is equivalent to converting(void*)0to the same integer type. A value of typenullptr_tcan be converted to a pointer type ornullptr_t, the result is a null pointer.
Note: The text currently says "The type
nullptr_tcan be converted ..." which is inconsistent with how other conversions are described on values rather than types.
Note: It seems unnecessary to define the conversion of nullptr_t to
void here.