What does contain mean in [dcl.constexpr]/3?

31 views
Skip to first unread message

Anders Granlund

unread,
Jul 24, 2015, 10:04:39 PM7/24/15
to ISO C++ Standard - Discussion
In [dcl.constexpr]/3 (http://eel.is/c++draft/dcl.constexpr#3), what does contain mean in "or a compound-statement that does not contain"?

For example:

constexpr void f() {
    struct S {
        static void g() { goto x; x: ; }
    };
}

int main() {}

Does the compound statement that makes up f:s body contain the goto-statement?

Johannes Schaub

unread,
Jul 25, 2015, 2:20:17 AM7/25/15
to std-dis...@isocpp.org

I would say no, because "Unless otherwise stated, utterances
in Clause 7 about components in, of, or contained by a declaration or subcomponent thereof refer only to
those components of the declaration that are not nested within scopes nested within the declaration.".

Anders Granlund

unread,
Jul 25, 2015, 6:41:58 AM7/25/15
to std-dis...@isocpp.org
But the compound statement that makes up f:s body is not a declaration, so that does not apply.

Here is an example where we don't even have declarations nested inside f:s body:

void f() {
    []() -> void { goto x; x: return; };
}

int main() {}




--

---
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.
To post to this group, send email to std-dis...@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-discussion/.

Anders Granlund

unread,
Jul 25, 2015, 6:47:35 AM7/25/15
to std-dis...@isocpp.org
Should be 

constexpr void f() {
    []() -> void { goto x; x: return; };
}

int main() {}

Johannes Schaub

unread,
Jul 25, 2015, 5:41:43 PM7/25/15
to std-dis...@isocpp.org


Am 25.07.2015 12:41 schrieb "Anders Granlund" <anders.g...@gmail.com>:
>
> But the compound statement that makes up f:s body is not a declaration, so that does not apply.
>

It still applies because it says "declaration or a subcomponent thereof".

Anders Granlund

unread,
Jul 26, 2015, 7:26:28 AM7/26/15
to std-dis...@isocpp.org
But wouldn't then the following program be well-formed, by the same logics?

constexpr void f() {
    {
        goto x; x: return;
    }
}

int main() {}

--

Johannes Schaub

unread,
Jul 26, 2015, 9:29:54 AM7/26/15
to std-dis...@isocpp.org
IMO yes. Perhaps p2 should instead say

"Unless otherwise stated, utterances in Clause 7 about components in,
of, or contained by a declaration or subcomponent thereof refer only
to those components of the declaration that are not nested within
declarations nested within the declaration."
Reply all
Reply to author
Forward
0 new messages