C++ Logo

liaison

Advanced search

Re: [wg14/wg21 liaison] cv-qualified anonymous types and member access expressions

From: Aaron Ballman <aaron_at_[hidden]>
Date: Thu, 5 May 2022 11:23:18 -0400
On Thu, May 5, 2022 at 9:35 AM Jₑₙₛ Gustedt via Liaison
<liaison_at_[hidden]> wrote:
>
> Aaron,
>
> on Thu, 5 May 2022 09:01:47 -0400 you (Aaron Ballman via Liaison
> <liaison_at_[hidden]>) wrote:
>
> > 6.7.2.1p15: An unnamed member whose type specifier is a structure
> > specifier with no tag is called an anonymous structure; an unnamed
> > member whose type specifier is a union specifier with no tag is called
> > an anonymous union. The members of an anonymous structure or union are
> > considered to be members of the containing structure or union, keeping
> > their structure or union layout. This applies recursively if the
> > containing structure or union is also anonymous.
>
> > ...
>
> > I *think* what may have been intended is for 6.7.2.1p15 to instead say
> > something along the lines of: ... The members of an anonymous
> > structure or union are considered to be members of the containing
> > structure or union, keeping their structure or union layout <ins>and
> > the qualifiers specified for the unnamed member</ins>. ...
>
> This would have made that clearer, but I think that this already
> follows, anyhow. The type of `bar` is indeed `int const` and not
> `int`. The `const` of the surrounding structure comes from the part in
> 6.3.2.1p1 that you cited
>
> ... and if it is a structure or union, does not have any
> member (including, recursively, any member or element of all
> contained aggregates or unions) with a const-qualified type.
>
> This specification doesn't exclude unnamed members, and so
> `<anonymous>.bar` is not a modifiable lvalue.

I like that reading, thank you for this observation!

> But you are right that this could all be clearer by pushing it on the
> syntax somehow:
>
> If a member is an agreate or union type and is `const` or
> `volatile` qualified, all of its members, even recursively are
> so qualified.

Yeah, I think we could make this a bit more clear editorially if we
thought that was a good idea.

~Aaron

> Jₑₙₛ
>
> --
> :: INRIA Nancy Grand Est ::: Camus ::::::: ICube/ICPS :::
> :: :::::::::::::::::::::: gsm France : +33 651400183 ::
> :: ::::::::::::::: gsm international : +49 15737185122 ::
> :: http://icube-icps.unistra.fr/index.php/Jens_Gustedt ::
> _______________________________________________
> Liaison mailing list
> Liaison_at_[hidden]
> Subscription: https://lists.isocpp.org/mailman/listinfo.cgi/liaison
> Link to this post: http://lists.isocpp.org/liaison/2022/05/1060.php

Received on 2022-05-05 15:23:32