Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

19 May, 2024: Line wrapping has been changed to be more consistent with Usenet standards.
 If you find that it is broken please let me know here rocksolid.nodes.help


devel / comp.std.c / Re: Footnote in section on Address-Of Operator

SubjectAuthor
* Footnote in section on Address-Of OperatorJoJoModding
`* Re: Footnote in section on Address-Of OperatorBen Bacarisse
 `* Re: Footnote in section on Address-Of OperatorTim Rentsch
  `- Re: Footnote in section on Address-Of OperatorBen Bacarisse

1
Footnote in section on Address-Of Operator

<3aa216b0-365a-42b0-aceb-959cf5a1a747n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=475&group=comp.std.c#475

  copy link   Newsgroups: comp.std.c
X-Received: by 2002:a05:622a:1c11:b0:3a5:13b0:e040 with SMTP id bq17-20020a05622a1c1100b003a513b0e040mr10538798qtb.625.1669243252364;
Wed, 23 Nov 2022 14:40:52 -0800 (PST)
X-Received: by 2002:a05:6870:8644:b0:142:78d4:344d with SMTP id
i4-20020a056870864400b0014278d4344dmr15346000oal.104.1669243252121; Wed, 23
Nov 2022 14:40:52 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.std.c
Date: Wed, 23 Nov 2022 14:40:51 -0800 (PST)
Injection-Info: google-groups.googlegroups.com; posting-host=134.96.204.97; posting-account=bU-zqAoAAAAnHdXcADIpHCljXjHw9VkC
NNTP-Posting-Host: 134.96.204.97
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <3aa216b0-365a-42b0-aceb-959cf5a1a747n@googlegroups.com>
Subject: Footnote in section on Address-Of Operator
From: jojohostert@gmail.com (JoJoModding)
Injection-Date: Wed, 23 Nov 2022 22:40:52 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 2300
 by: JoJoModding - Wed, 23 Nov 2022 22:40 UTC

Hi all,

in the paragraph on address and indirection operators (6.5.3.2 in the C23 draft N3047), there is a footnote (footnote 117 in that draft), which says that

> &*E is equivalent to E (even if E is a null pointer)

This seems to imply that sizeof(&*E) == sizeof(E), which is unexpected if E is an array. For example, on most C compilers, we have sizeof("foo") == strlen("foo")+1, while sizeof(&*"foo") == sizeof(char*). So clearly they are not equivalent.

Further, we have that
> If an invalid value has been assigned to the pointer, the behavior of the unary * operator is undefined.

However the footnote says that &*E is equivalent to E, so if E is an invalid pointer value, *E would be undefined behavior, but &*E is not? (I'm aware that compilers may treat them equivalent, but this is precisely because *E has undefined behavior even if the immediate child of an & operator.) The sentence quoted above is not part of the constraints, so &* does still remove UB even though "the constraints on the operators still apply"?

How is one to read this footnote, and the paragraph in general? Why does it try to say that things are "equivalent" that sometimes are not?

Thanks,
Johannes

Re: Footnote in section on Address-Of Operator

<87pmddi5e7.fsf@bsb.me.uk>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=476&group=comp.std.c#476

  copy link   Newsgroups: comp.std.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: ben.usenet@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.std.c
Subject: Re: Footnote in section on Address-Of Operator
Date: Thu, 24 Nov 2022 00:05:04 +0000
Organization: A noiseless patient Spider
Lines: 53
Message-ID: <87pmddi5e7.fsf@bsb.me.uk>
References: <3aa216b0-365a-42b0-aceb-959cf5a1a747n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: reader01.eternal-september.org; posting-host="66cc716c1d8e20186aec3fe895a20c78";
logging-data="511210"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19+eqYfIB71UB2EcsO4ujEC9fGHH3oq1eQ="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:RgtCd85zXB0qT1Qh6rYWIFsUFQ4=
sha1:zy6zY6DoOelceKjAgj70hN9BZwU=
X-BSB-Auth: 1.47417ea1dbc88d1e2f62.20221124000504GMT.87pmddi5e7.fsf@bsb.me.uk
 by: Ben Bacarisse - Thu, 24 Nov 2022 00:05 UTC

JoJoModding <jojohostert@gmail.com> writes:

> in the paragraph on address and indirection operators (6.5.3.2 in the
> C23 draft N3047), there is a footnote (footnote 117 in that draft),
> which says that
>
>> &*E is equivalent to E (even if E is a null pointer)

This seems to be a case where a footnote might add confusion rather than
clarity. The normative text makes it clear that &*E can't be equivalent
to E in every way because &*E is not an lvalue. And &*E has type
constraints that E does not have.

> This seems to imply that sizeof(&*E) == sizeof(E), which is unexpected
> if E is an array.

There are much simpler examples if the apparent non-equivalence. If p
is a pointer object, p can be assigned to by &*p can't be. And due to
the clause about constraints. &*(void *)0 is a constraint violation,
but (void *)0 is obviously fine.

I say "apparent" because equivalence is a slippery term. It does not
mean "exactly the same as" but something much less specific so it may
have been chosen for this very reason.

> Further, we have that
>> If an invalid value has been assigned to the pointer, the behavior of
>> the unary * operator is undefined.
>
> However the footnote says that &*E is equivalent to E, so if E is an
> invalid pointer value, *E would be undefined behavior, but &*E is not?

Yes &*p is fine even if p is an invalid pointer because undefined
behaviour only exists if *p is evaluated, and nether the * nor the & are
evaluated in &*p.

> ... &* does still remove UB even though "the constraints on the
> operators still apply"?

It removes some but not all. &*0 is a constraint violation (and hence
UB), but &*(int *)0 is not. De-referencing a null pointer is not a
constraint violation.

> How is one to read this footnote, and the paragraph in general? Why
> does it try to say that things are "equivalent" that sometimes are
> not?

Well, I think it means equivalent in some ways and not in others. But
I'm not sure it adds any clarity to the normative wording that has been
around for many years.

--
Ben.

Re: Footnote in section on Address-Of Operator

<86o7sx83uf.fsf@linuxsc.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=478&group=comp.std.c#478

  copy link   Newsgroups: comp.std.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: tr.17687@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.std.c
Subject: Re: Footnote in section on Address-Of Operator
Date: Wed, 23 Nov 2022 18:48:40 -0800
Organization: A noiseless patient Spider
Lines: 25
Message-ID: <86o7sx83uf.fsf@linuxsc.com>
References: <3aa216b0-365a-42b0-aceb-959cf5a1a747n@googlegroups.com> <87pmddi5e7.fsf@bsb.me.uk>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: reader01.eternal-september.org; posting-host="8ee213438f0e6ab517cae470e775d09b";
logging-data="532317"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19eAmnCPCYm+ygO2u40XcM7STrbqS6Cswg="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:mAQvcPchfd+ylfuD25JvTJ+5zU4=
sha1:rc0sUE5zvg/MHesLw3R+5NmRcfk=
 by: Tim Rentsch - Thu, 24 Nov 2022 02:48 UTC

Ben Bacarisse <ben.usenet@bsb.me.uk> writes:

> JoJoModding <jojohostert@gmail.com> writes:
>
>> in the paragraph on address and indirection operators (6.5.3.2 in the
>> C23 draft N3047), there is a footnote (footnote 117 in that draft),
>> which says that
>>
>>> &*E is equivalent to E (even if E is a null pointer)
>
> This seems to be a case where a footnote might add confusion rather than
> clarity. The normative text makes it clear that &*E can't be equivalent
> to E in every way because &*E is not an lvalue. And &*E has type
> constraints that E does not have.
>
>> This seems to imply that sizeof(&*E) == sizeof(E), which is unexpected
>> if E is an array.
>
> There are much simpler examples if the apparent non-equivalence. If p
> is a pointer object, p can be assigned to by &*p can't be. And due to
> the clause about constraints. &*(void *)0 is a constraint violation,
> but (void *)0 is obviously fine.

What makes you say &*(void*)0 is a constraint violation? I
don't see any constraints that are violated.

Re: Footnote in section on Address-Of Operator

<8735a8iive.fsf@bsb.me.uk>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=479&group=comp.std.c#479

  copy link   Newsgroups: comp.std.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: ben.usenet@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.std.c
Subject: Re: Footnote in section on Address-Of Operator
Date: Thu, 24 Nov 2022 13:26:13 +0000
Organization: A noiseless patient Spider
Lines: 33
Message-ID: <8735a8iive.fsf@bsb.me.uk>
References: <3aa216b0-365a-42b0-aceb-959cf5a1a747n@googlegroups.com>
<87pmddi5e7.fsf@bsb.me.uk> <86o7sx83uf.fsf@linuxsc.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: reader01.eternal-september.org; posting-host="66cc716c1d8e20186aec3fe895a20c78";
logging-data="707126"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/4XtkAvShH3c5ZviDYu/qN9PyMVxVOsJE="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:3dNDXm+Jp7qBganyOzU3R1afDj4=
sha1:3RvHh54Jr7Q9rSKeqOKupBs/Q1g=
X-BSB-Auth: 1.5e11572890e10577949b.20221124132613GMT.8735a8iive.fsf@bsb.me.uk
 by: Ben Bacarisse - Thu, 24 Nov 2022 13:26 UTC

Tim Rentsch <tr.17687@z991.linuxsc.com> writes:

> Ben Bacarisse <ben.usenet@bsb.me.uk> writes:
>
>> JoJoModding <jojohostert@gmail.com> writes:
>>
>>> in the paragraph on address and indirection operators (6.5.3.2 in the
>>> C23 draft N3047), there is a footnote (footnote 117 in that draft),
>>> which says that
>>>
>>>> &*E is equivalent to E (even if E is a null pointer)
>>
>> This seems to be a case where a footnote might add confusion rather than
>> clarity. The normative text makes it clear that &*E can't be equivalent
>> to E in every way because &*E is not an lvalue. And &*E has type
>> constraints that E does not have.
>>
>>> This seems to imply that sizeof(&*E) == sizeof(E), which is unexpected
>>> if E is an array.
>>
>> There are much simpler examples if the apparent non-equivalence. If p
>> is a pointer object, p can be assigned to by &*p can't be. And due to
>> the clause about constraints. &*(void *)0 is a constraint violation,
>> but (void *)0 is obviously fine.
>
> What makes you say &*(void*)0 is a constraint violation? I
> don't see any constraints that are violated.

Isn't * applied to a pointer to an incomplete type a constraint? Let me
go look... ah, no it is not! Thanks.

--
Ben.


devel / comp.std.c / Re: Footnote in section on Address-Of Operator

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor