Title
Which namespace std is the mentioned one?
Status
new
Section
[namespace.std]
Submitter
jim x

Created on 2023-04-19.00:00:00 last changed 18 months ago

Messages

Date: 2023-05-24.14:33:00

Proposed resolution:

This wording is relative to N4944.

  1. Modify [namespace.std] as indicated:

    -?- The restrictions on the use of namespace std apply only to a top-level namespace named std. Namespaces named std nested in program-defined namespaces are not restricted this way or otherwise reserved.

    -1- Unless otherwise specified, the behavior of a C++ program is undefined if it adds declarations or definitions to namespace std or to a namespace within namespace std.

Date: 2023-05-15.00:00:00

[ 2023-05-24; Reflector poll ]

Set priority to 4 after reflector poll.

Date: 2023-04-15.00:00:00

[ 2023-04-24; Ville provides wording ]

Date: 2023-04-19.00:00:00

[namespace.std] p1 says

Unless otherwise specified, the behavior of a C++ program is undefined if it adds declarations or definitions to namespace std or to a namespace within namespace std.

Which std namespace does the rule intend to refer to? Does the text refer to any namespace named std? Consider this case:

namespace A{
   namespace std{  // UB or not? 
      void show(){}
      namespace B{
         void fun(){}  // UB or not? 
     }
  }
}
int main(){  
}

A resemble usage like the above example can be seen in a libcudacxx github code, for example.

Suggested resolution:

We may want to say the namespace std only refers to the namespace whose declaration inhabits the global scope.

[namespace.std] p2, p7 that refers to namespace std have a similar issue.

History
Date User Action Args
2023-05-24 14:33:00adminsetmessages: + msg13575
2023-04-29 09:02:50adminsetmessages: + msg13534
2023-04-29 09:02:50adminsetmessages: + msg13533
2023-04-19 00:00:00admincreate