Sujet : Re: question about nullptr
De : 643-408-1753 (at) *nospam* kylheku.com (Kaz Kylheku)
Groupes : comp.lang.cDate : 09. Jul 2024, 23:25:34
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <20240709152019.544@kylheku.com>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14
User-Agent : slrn/pre1.0.4-9 (Linux)
On 2024-07-09, Thiago Adams <
thiago.adams@gmail.com> wrote:
On 09/07/2024 08:32, Tim Rentsch wrote:
Any use of '\0' almost always strikes me as an affectation. It's
like people want to somehow pretend that it's not the same as
just 0.
>
I like to pretend
>
'\0' is not int
In C++ it isn't.
void foo(int);
void foo(char);
foo(0); // takes int overload
foo('\0'); // takes char overload
I don't like to think '\0' is null pointer.
I don't like that 1 - 1 is a null pointer. It's not a good design.
Nobody other than C humorists needs any zero-valued integer expression
whatsoever to be a null pointer constant.
How it should work is that only the token 0 is a null pointer constant.
Not 0L (ideally, not even 00 or 0x0, only the decimal token).
All zero-valued constant expressions of integer type should not be
null pointer constants, but ordinary expressions whch require
a cast to be converted to pointer type, and denote an address
associated with zero that may be different from the null pointer.
-- TXR Programming Language: http://nongnu.org/txrCygnal: Cygwin Native Application Library: http://kylheku.com/cygnalMastodon: @Kazinator@mstdn.ca