Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Kaz Kylheku <643-408-1753@kylheku.com> Newsgroups: comp.lang.c Subject: Re: question about nullptr Date: Tue, 9 Jul 2024 22:25:34 -0000 (UTC) Organization: A noiseless patient Spider Lines: 38 Message-ID: <20240709152019.544@kylheku.com> References: <20240706054641.175@kylheku.com> <877cdyuq0f.fsf@bsb.me.uk> <2ckiO.19403$7Ej.4487@fx46.iad> <87plrpt4du.fsf@bsb.me.uk> <9bCiO.7108$sXW9.3805@fx41.iad> <877cdwu9s1.fsf@nosuchdomain.example.com> <20240708222804.00001654@yahoo.com> <20240709104848.00005732@yahoo.com> <86cynmajh9.fsf@linuxsc.com> Injection-Date: Wed, 10 Jul 2024 00:25:34 +0200 (CEST) Injection-Info: dont-email.me; posting-host="7b522d35a8b6a4705d66078d67bdff1e"; logging-data="1644188"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19AnQ21uNz505C8O6mS1w19TOL3EfWpns4=" User-Agent: slrn/pre1.0.4-9 (Linux) Cancel-Lock: sha1:hfT4Gn5HdNwADkwOJgqVGLieCkE= Bytes: 2475 On 2024-07-09, Thiago Adams 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/txr Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal Mastodon: @Kazinator@mstdn.ca