std
is the mentioned one?Section: 16.4.5.2.1 [namespace.std] Status: New Submitter: jim x Opened: 2023-04-19 Last modified: 2023-05-24
Priority: 4
View other active issues in [namespace.std].
View all other issues in [namespace.std].
View all issues with New status.
Discussion:
16.4.5.2.1 [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 namespacestd
.
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 namespacestd
only refers to the namespace whose declaration inhabits the global scope.
16.4.5.2.1 [namespace.std] p2, p7 that refers to namespace std
have a similar issue.
[2023-04-24; Ville provides wording]
[2023-05-24; Reflector poll]
Set priority to 4 after reflector poll.
Proposed resolution:
This wording is relative to N4944.
Modify 16.4.5.2.1 [namespace.std] as indicated:
-?- The restrictions on the use of namespace
-1- Unless otherwise specified, the behavior of a C++ program is undefined if it adds declarations or definitions to namespacestd
apply only to a top-level namespace namedstd
. Namespaces namedstd
nested in program-defined namespaces are not restricted this way or otherwise reserved.std
or to a namespace within namespacestd
.