L
Lauri Alanko
Is ((uintptr_t) NULL) guaranteed to be converted into a null pointer
when cast into void*? At first glance one would think so, but to my
understanding NULL might be defined as 0, and there is no guarantee
that a null pointer gets converted into an integer 0 when cast to
uintptr_t.
So one needs to explicitly use ((uintptr_t) (void*) 0) which seems a
bit clunky. Is my reasoning correct?
Also, what's the reason that NULL is allowed to be a plain integer
constant instead of an expression with a pointer type? I can't see any
benefit from it, and it leads to confusion in rare corner cases such
as this one.
Thanks,
Lauri
when cast into void*? At first glance one would think so, but to my
understanding NULL might be defined as 0, and there is no guarantee
that a null pointer gets converted into an integer 0 when cast to
uintptr_t.
So one needs to explicitly use ((uintptr_t) (void*) 0) which seems a
bit clunky. Is my reasoning correct?
Also, what's the reason that NULL is allowed to be a plain integer
constant instead of an expression with a pointer type? I can't see any
benefit from it, and it leads to confusion in rare corner cases such
as this one.
Thanks,
Lauri