Re: Transitioning libgomp from C to C++ implementation

Jonathan Wakely via Gcc <[email protected]>
Newsgroups gmane.comp.gcc.devel
Message-ID <CAH6eHdRkYM_edmNn_vmQL=UJxN3WkJia_=WddgphUVP_hdHu2g@mail.gmail.com>
On Sat, 9 May 2026, 09:40 Christopher Bazley via Gcc, <[email protected]>
wrote:

>
>
> This flaw in the design of C++ is also what necessitated the invention
> of nullptr, which would otherwise be unnecessary. Had the purpose of
> 'void *' not been misunderstood, nullptr could simply have been defined
> as a macro: ((void *)0).


No it couldn't.

This thread is getting more and more of topic, but defining nullptr as just
a void* would not allow the useful property of overloading functions like
unique_ptr::operator= on whether the argument is an actual pointer (which
would replace the owned pointer, but is disallowed by plain assignment) or
is the special nullptr value (which is allowed).

That is:

uptr = (void*)0; // error
uptr = nullptr; // ok

I think you have an overly simplistic idea of why nullptr was added to C++,
leading to an incorrect conclusion about it only being necessary because of
C++ pointer conversion rules.

It exists for reasons related to template type deduction and overloading,
not because void* isn't convertible to other pointer types.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.