Title
Nested unnamed namespace of inline unnamed namespace
Status
drafting
Section
9.8.2.2 [namespace.unnamed]
Submitter
Nathan Sidwell

Created on 2021-11-22.00:00:00 last changed 26 months ago

Messages

Date: 2021-12-15.00:00:00

Notes from the December, 2021 teleconference:

The suggested resolution deals specifically with unnamed namespaces, but there are related examples that do not involve unnamed namespaces. The problem needs to be solved more generally in the specification of lookup.

Date: 2022-02-18.07:47:23

Suggested resolution:

Change 9.8.2.2 [namespace.unnamed] paragraph 1 as follows:

...where inline appears if and only if it appears in the unnamed-namespace-definition and all occurrences of unique in each scope in a translation unit are replaced by the same scope-specific identifier, and this identifier differs from all other identifiers in the translation unit.
Date: 2022-02-18.07:47:23

According to 9.8.2.2 [namespace.unnamed] paragraph 1,

An unnamed-namespace-definition behaves as if it were replaced by

    inlineopt namespace unique { /* empty body */ }
    using namespace unique ;
    namespace unique { namespace-body }

where inline appears if and only if it appears in the unnamed-namespace-definition and all occurrences of unique in a translation unit are replaced by the same identifier, and this identifier differs from all other identifiers in the translation unit.

The use of a single identifier for all occurrences of unique within a translation unit leads to problems when an inline unnamed namespace contains a nested unnamed namespace, e.g.,

    inline namespace {
      namespace { }
    }

In this case, the unnamed namespace cannot be reopened because the lookup for unique finds both the outer and inner namespaces and is thus ambiguous.

History
Date User Action Args
2022-02-18 07:47:23adminsetmessages: + msg6725
2022-01-06 00:00:00adminsetmessages: + msg6612
2022-01-06 00:00:00adminsetstatus: open -> drafting
2021-11-22 00:00:00admincreate