The word 'except' in [basic.scope.pdecl]/1 seems misleading.

54 views
Skip to first unread message

Alexander

unread,
Apr 15, 2018, 8:33:19 AM4/15/18
to ISO C++ Standard - Discussion
[basic.scope.pdecl]/1 (my emphasis)

The point of declaration for a name is immediately after its complete declarator (Clause 11) and before its
initializer (if any), except as noted below. [ Example:
      unsigned char x = 12;
    { unsigned char x = x; }
Here the second x is initialized with its own (indeterminate) value. —end example ]

It seems to me the term except above suggests that the example contradicts the rule, whereas the second x is initialized with an indeterminate value exactly because the point of the declaration of x comes after its complete declarator and before its initializer.

Nicolas Lesser

unread,
Apr 15, 2018, 8:38:32 AM4/15/18
to std-dis...@isocpp.org
Notes and examples are non-nominative. They don't count and as such are not included in the "below" that the last sentence refers to. Don't know if this counts as misleading or not :)

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-discussion+unsubscribe@isocpp.org.
To post to this group, send email to std-dis...@isocpp.org.
Visit this group at https://groups.google.com/a/isocpp.org/group/std-discussion/.

Alexander

unread,
Apr 15, 2018, 8:44:16 AM4/15/18
to ISO C++ Standard - Discussion
On Sunday, April 15, 2018 at 9:38:32 AM UTC-3, Nicolas Lesser wrote:
Notes and examples are non-nominative. They don't count and as such are not included in the "below" that the last sentence refers to. Don't know if this counts as misleading or not :)

I'm just saying that  the paragraph would be much clearer with he word 'except' deleted.

Nicolas Lesser

unread,
Apr 15, 2018, 8:49:39 AM4/15/18
to std-dis...@isocpp.org
But you can't delete it! It's necessary, and maybe it would make sense to reword it, I don't just don't know.

Without it, something like

using Foo = int;
Foo f; // oh no, ill-formed

will be ill-formed because name `Foo` doesn't have a declarator. 

--

Bo Persson

unread,
Apr 15, 2018, 9:03:21 AM4/15/18
to std-dis...@isocpp.org
On 2018-04-15 14:33, Alexander wrote:
> [basic.scope.pdecl]/1 <http://eel.is/c++draft/basic.scope.pdecl#1> (my
> emphasis)
>
> The /point of declaration/ for a name is immediately after its
> complete declarator (Clause 11) and before its
> /initializer/ (if any), *except* as noted below. [ Example:
>    unsigned char x = 12;
>     { unsigned char x = x; }
> Here the second x is initialized with its own (indeterminate) value.
> —end example ]
>
>
> It seems to me the term *except* above suggests that the example
> contradicts the rule, whereas the second x is initialized with an
> indeterminate value exactly because the point of the declaration of
> xcomes after its complete /declarator/ and before its /initializer/.
>

Not extremely clear perhaps, but I read "except" as referring to the
rules in the rest of the section, not to the example immediately following.


Bo Persson

Alexander

unread,
Apr 15, 2018, 9:19:59 AM4/15/18
to ISO C++ Standard - Discussion


On Sunday, April 15, 2018 at 9:49:39 AM UTC-3, Nicolas Lesser wrote:
But you can't delete it! It's necessary, and maybe it would make sense to reword it, I don't just don't know.

Without it, something like

using Foo = int;
Foo f; // oh no, ill-formed

will be ill-formed because name `Foo` doesn't have a declarator. 

That's not correct. An alias-declaration doesn't have a declarator by definition. See alias-declaration.

Nicolas Lesser

unread,
Apr 15, 2018, 9:23:17 AM4/15/18
to std-dis...@isocpp.org
Isn't that what I said? Without this except, there wouldn't be any named introduced by the using declaration, so that's why it's important :)

Alexander

unread,
Apr 15, 2018, 10:11:19 AM4/15/18
to ISO C++ Standard - Discussion, b...@gmb.dk
On Sunday, April 15, 2018 at 10:03:21 AM UTC-3, Bo Persson wrote:


Not extremely clear perhaps, but I read "except" as referring to the
rules in the rest of the section, not to the example immediately following.

After thinking about this for a while,I believe you're right. But a rewording would still be desirable, perhaps with something like "except as noted in the following paragraphs". Thanks.

Alexander

unread,
Apr 15, 2018, 11:35:02 AM4/15/18
to ISO C++ Standard - Discussion


On Sunday, April 15, 2018 at 10:23:17 AM UTC-3, Nicolas Lesser wrote:

Isn't that what I said? Without this except, there wouldn't be any named introduced by the using declaration, so that's why it's important :)

You are confusing things again. In your example using Foo int; is an alias-declaration, not a using-declaration. And so, assuming that the answer given by Bo Person is correct, one should then conclude that a paragraph is missing in 6.3.2 [basic.scope.pdecl], to handle the exception involved in an alias-declaration, which doesn't have a declarator.

Nicolas Lesser

unread,
Apr 15, 2018, 11:59:38 AM4/15/18
to std-dis...@isocpp.org
Oh that's true. I need to be careful then :) Thanks

--

Johannes Schaub

unread,
Apr 15, 2018, 12:24:14 PM4/15/18
to std-dis...@isocpp.org
Not sure I'm following you. In "using Foo = int", there is an
exception to the general rule that the point of declaration of a name
is immediately following its declarator. Namely: "The point of
declaration of an alias or alias template immediately follows the
type-id to which the alias refers." . Without this exception, "Foo"
wouldn't have a "point of declaration" or the general rule would be
ill-worded (pick your favourite), because there's no declarator.

Alexander

unread,
Apr 15, 2018, 1:19:19 PM4/15/18
to ISO C++ Standard - Discussion

On Sunday, April 15, 2018 at 1:24:14 PM UTC-3, Johannes Schaub wrote:

Not sure I'm following you. In "using Foo = int", there is an
exception to the general rule that the point of declaration of a name
is immediately following its declarator. Namely: "The point of
declaration of an alias or alias template immediately follows the
type-id to which the alias refers." . Without this exception, "Foo"
wouldn't have a "point of declaration" or the general rule would be
ill-worded (pick your favourite), because there's no declarator.

You're completely right. I missed that part in paragraph 3. Thus, there is o need for a new paragraph in 6.3.2 [basic.scope.pdecl] to handle this exception.  

Tony V E

unread,
Apr 15, 2018, 1:25:02 PM4/15/18
to ISO C++ Standard - Discussion
Regardless of the technical conclusion, the real conclusion is that the note/example is in a confusing spot.
Maybe it could be moved up a bit, or moved down past the list of exceptions, where you could have examples of all cases.


Sent from my BlackBerry portable Babbage Device
From: Alexander
Sent: Sunday, April 15, 2018 1:19 PM
To: ISO C++ Standard - Discussion
Subject: Re: [std-discussion] The word 'except' in [basic.scope.pdecl]/1 seems misleading.

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-discussio...@isocpp.org.

Richard Smith

unread,
Apr 15, 2018, 5:24:41 PM4/15/18
to std-dis...@isocpp.org
On 15 April 2018 at 10:24, Tony V E <tvan...@gmail.com> wrote:
Regardless of the technical conclusion, the real conclusion is that the note/example is in a confusing spot.
Maybe it could be moved up a bit, or moved down past the list of exceptions, where you could have examples of all cases.

It seems to be in the right spot to me, as it's an example of the preceding sentence (particularly the "The point of declaration for a name is immediately after its complete declarator (Clause 11) and before its initializer (if any)" portion of it). Perhaps reordering the normative sentence to:

"Except as noted below, the point of declaration for a name is immediately after its complete declarator (Clause 11) and before its initializer (if any). [Example: ...]"

... would help? Feel free to file this as an editorial issue (github.com/cplusplus/draft).

And maybe we should replace that "Except as noted below" with a description of which cases this rule *actually* covers (that is, declarations that have declarators...).

Sent from my BlackBerry portable Babbage Device
From: Alexander
Sent: Sunday, April 15, 2018 1:19 PM
To: ISO C++ Standard - Discussion
Subject: Re: [std-discussion] The word 'except' in [basic.scope.pdecl]/1 seems misleading.

On Sunday, April 15, 2018 at 1:24:14 PM UTC-3, Johannes Schaub wrote:

Not sure I'm following you. In "using Foo = int", there is an
exception to the general rule that the point of declaration of a name
is immediately following its declarator. Namely: "The point of
declaration of an alias or alias template immediately follows the
type-id to which the alias refers." . Without this exception, "Foo"
wouldn't have a "point of declaration" or the general rule would be
ill-worded (pick your favourite), because there's no declarator.

You're completely right. I missed that part in paragraph 3. Thus, there is o need for a new paragraph in 6.3.2 [basic.scope.pdecl] to handle this exception.  

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-discussion+unsubscribe@isocpp.org.

To post to this group, send email to std-dis...@isocpp.org.
Visit this group at https://groups.google.com/a/isocpp.org/group/std-discussion/.

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-discussion+unsubscribe@isocpp.org.
Reply all
Reply to author
Forward
0 new messages