Re: question about nullptr

Liste des GroupesRevenir à cl c 
Sujet : Re: question about nullptr
De : Keith.S.Thompson+u (at) *nospam* gmail.com (Keith Thompson)
Groupes : comp.lang.c
Date : 26. Aug 2024, 02:18:23
Autres entêtes
Organisation : None to speak of
Message-ID : <87wmk4dqu8.fsf@nosuchdomain.example.com>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13
User-Agent : Gnus/5.13 (Gnus v5.13)
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 */

Date Sujet#  Auteur
6 Jul 24 * question about nullptr145Thiago Adams
6 Jul 24 +- Re: question about nullptr1Bonita Montero
6 Jul 24 +- Re: question about nullptr1John McCue
6 Jul 24 +* Re: question about nullptr114Kaz Kylheku
6 Jul 24 i+- Re: question about nullptr96Janis Papanagnou
6 Jul 24 i+* Re: question about nullptr4bart
7 Jul 24 ii`* Re: question about nullptr3Lawrence D'Oliveiro
7 Jul 24 ii +- Re: question about nullptr1Keith Thompson
7 Jul 24 ii `- Re: question about nullptr1bart
12 Jul 24 i`* Re: question about nullptr13Richard Harnden
12 Jul 24 i +* Re: question about nullptr4Kaz Kylheku
13 Jul 24 i i`* Re: question about nullptr3Kaz Kylheku
13 Jul 24 i i +- Re: question about nullptr1James Kuyper
13 Jul 24 i i `- Re: question about nullptr1Keith Thompson
14 Jul 24 i +- Re: question about nullptr1Tim Rentsch
15 Jul 24 i `* Re: question about nullptr7Lawrence D'Oliveiro
16 Jul 24 i  +- Re: question about nullptr1Keith Thompson
16 Jul 24 i  `* Re: question about nullptr5James Kuyper
16 Jul 24 i   +- Re: question about nullptr1Keith Thompson
25 Aug 24 i   `* Re: question about nullptr3dave thompson 2
25 Aug 24 i    +- Re: question about nullptr1Richard Damon
26 Aug 24 i    `- Re: question about nullptr1James Kuyper
6 Jul 24 `* Re: question about nullptr28Richard Damon
6 Jul 24  `* Re: question about nullptr27David Brown
7 Jul 24   +- Re: question about nullptr2Lawrence D'Oliveiro
7 Jul 24   +- Re: question about nullptr1Thiago Adams
9 Jul 24   `* Re: question about nullptr23Richard Harnden
9 Jul 24    `- Re: question about nullptr22Chris M. Thomasson

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal