Deutsch   English   Français   Italiano  
<v6gv4f$tp07$1@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: James Kuyper <jameskuyper@alumni.caltech.edu>
Newsgroups: comp.lang.c
Subject: Re: question about nullptr
Date: Mon, 8 Jul 2024 11:03:42 -0400
Organization: A noiseless patient Spider
Lines: 24
Message-ID: <v6gv4f$tp07$1@dont-email.me>
References: <v6bavg$3pu5i$1@dont-email.me> <20240706054641.175@kylheku.com>
 <v6bfi1$3qn4u$1@dont-email.me> <l9ciO.7$cr5e.2@fx05.iad>
 <877cdyuq0f.fsf@bsb.me.uk> <2ckiO.19403$7Ej.4487@fx46.iad>
 <87plrpt4du.fsf@bsb.me.uk> <9bCiO.7108$sXW9.3805@fx41.iad>
 <87jzhwu5v9.fsf@bsb.me.uk>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 08 Jul 2024 17:03:43 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="82ac0bc5ac8679abf13c09bba0ac1135";
	logging-data="975879"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1/ZNu9x6XQqWnRz3vhxB45Y5cM27XlTAsQ="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:ig8LHws1Il2GohKToWPaCyFjgec=
Content-Language: en-US
In-Reply-To: <87jzhwu5v9.fsf@bsb.me.uk>
Bytes: 2149

On 7/7/24 19:42, Ben Bacarisse wrote:
> scott@slp53.sl.home (Scott Lurndal) writes:
....
>> I.e. it can either be a null pointer or the value zero
>> depending on context, which makes it ambiguous to the casual
>> reader. Particularly when reading code that someone
>> else has written. NULL makes the programmers intent crystal
>> clear.
>
> That's a rather niche readership -- one that might consider
>
> char *p = 0;
>
> unclear. Do you want such people reading your C code with a view to
> working on it?


The problem is not "char p=0;". If you're sure what type p has, there's
no problem. The problem comes with code like "p=0", where "p=NULL" would
serve to remind you that p should be a pointer, while "p=nullptr"
guarantees a diagnostic if p is not a pointer. I have fixed bugs which
would have been caught a lot earlier if nullptr had existed, and had
been the only permitted kind of null pointer constant.