| Deutsch English Français Italiano |
|
<87wmk4dqu8.fsf@nosuchdomain.example.com> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith Thompson <Keith.S.Thompson+u@gmail.com>
Newsgroups: comp.lang.c
Subject: Re: question about nullptr
Date: Sun, 25 Aug 2024 18:18:23 -0700
Organization: None to speak of
Lines: 40
Message-ID: <87wmk4dqu8.fsf@nosuchdomain.example.com>
References: <v6bavg$3pu5i$1@dont-email.me>
<90c2181ae4c7aac8f17f076093923d5b357c43aa@i2pn2.org>
<v6bt15$3svoi$1@dont-email.me> <v6iik7$1948o$1@dont-email.me>
<v6iklk$19cv8$1@dont-email.me> <v6inai$19q6r$1@dont-email.me>
<v6insm$19uag$1@dont-email.me> <874j8yswha.fsf@bsb.me.uk>
<v6k6a3$1gsq2$3@dont-email.me> <v6k6ha$1gsq2$4@dont-email.me>
<v6m87m$1v1rh$1@dont-email.me>
<cj6ncj93220a0hmgj64itsrlmngfmur44h@4ax.com>
<vagjcl$25csn$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Date: Mon, 26 Aug 2024 03:18:23 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="bc88295ca556238feaf2ba55fe5de0e2";
logging-data="2283292"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18rUVSbPeJ1USw4W6YhgCrJ"
User-Agent: Gnus/5.13 (Gnus v5.13)
Cancel-Lock: sha1:zMBAZEpAqfxdvWaIxDbGvoa3F1g=
sha1:rBqWt8pPvZuo5q1o87BWV8twpM4=
Bytes: 2980
James Kuyper <jameskuyper@alumni.caltech.edu> writes:
> On 8/25/24 16:56, dave_thompson_2@comcast.net wrote:
>> On Wed, 10 Jul 2024 11:09:41 -0400, James Kuyper
>> <jameskuyper@alumni.caltech.edu> wrote:
>>
>>> NULL is required to expand
>>> into a null pointer constant ... 0 and (void*)0 are the
>>> two most likely and common choices.
>>>
>> ((void*)0)
>>
>> Otherwise NULL["foo"] gives quite the wrong result
>
> Correct. Sorry.
A mostly meaningless price of trivia: In C17 and earlier, an excessively
literal reading of the standard implies that ((void*)0) is not a null
pointer constant. It says that a null pointer constant is "An integer
constant expression with the value 0, or such an expression cast to type
void *". It does not say that a parenthesized null pointer constant is
a null pointer constant. (And (void*)0 is a null pointer constant but
not a valid definition for NULL.)
C23 fixes this by updating the wording for parenthesized expressions.
C17: "A *parenthesized expression* is a primary expression. Its type and
value are identical to those of the unparenthesized expression. It is an
lvalue, a function designator, or a void expression if the
unparenthesized expression is, respectively, an lvalue, a function
designator, or a void expression."
C23: "A *parenthesized expression* is a primary expression. Its type,
value, and semantics are identical to those of the unparenthesized
expression."
This was surely the intent all along.
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */