3 ms·
> That doesn't make any sense to me. void* is a type isn't it? nullptr is a value. I don't see the overlap The C standard permits NULL to be defined as (void*)
by hgs3 4y ago
> That doesn't make any sense to me. void* is a type isn't it? nullptr is a value. I don't see the overlap
The C standard permits NULL to be defined as (void*)0 or 0. The issue is this creates an inconstancy when NULL is used with _Generic selection: a compiler defining NULL as (void*)0 will cause NULL to be caught by a pointer case whereas a compiler defining NULL as 0 will cause it to be caught by an integer case. This inconsistently could be solved by mandating NULL be defined as (void*)0 so it will always be caught by the pointer case.
The issue is instead of mandating (void*)0 the C committee decided to introduce a whole new nullptr concept. This duplicates the concept of null in the language and requires all C compiler vendors to modify the languages type system to account for it. So it creates more work for vendors and duplicates the concept of null all to solve this minor use case.
- deleted 4y ago[deleted]