News for hackers. Stuff that matters.
Re:GCC 13 Supports New C2x Features, Including Nullptr, Enha... by ori_b on Monday May 15, 2023 @03:46PM (#35953510)
That's a fine general sentiment. However, in this context it's a problem if you want to assign NULL to a pointer without a cast, which is why C++ added the magically convertible nullptr to add to the the magically convertible `0` constant.

     char *x = 0; // ok in C and C++
     char *y = (void*)0; // ok in C, error in C++
     char *z = nullptr; // ok in C++
This prevents C++ from defining NULL the way that Posix C does.

I don't understand why it's more acceptable to allow magic `0` conversions than magic `(void*)0` conversions, given that the latter is far less likely to happen by accident -- but here we are.

Re:GCC 13 Supports New C2x Features, Including Nullptr, Enha... by rightbyte on Monday May 15, 2023 @05:13PM (#35954564)
> I don't understand why it's more acceptable to allow magic `0` conversions than magic `(void*)0` conversions

In the end you don't have to chose between '0' and 'nullptr' anyways.

    char *x = (decltype (nullptr)) 0;