C++11 7.3.1/7 says, "If the optional initial inline keyword appears in a namespace-definition for a particular namespace, that namespace is declared to be an inline namespace. The inline keyword may be used on an extension-namespace-definition only if it was previously used on the original-namespace-definition for that namespace." I understand that this paragraph prohibits "retroactive inlining" of namespaces, like the following code; ///////////////////// namespace NS{} inline namespace NS{} ///////////////////// However, GCC 4.8.0 20120513 (experimental) with -std=c++11, -Wall and -Wpedantic accepts the above code without any warning. In addition, the document that explains the implementation of libstdc++ debug mode http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt03ch17s04.html#debug_mode.design.methods.coexistence includes an example code using retroactive inlining. It may mislead some readers to think that this is standard-conforming. Therefore, even if the current implementation of libstdc++ debug mode uses retroactive inlining, it's better to avoid this style in the document.
Confirmed.
Confirmed in 4.8.1. PS. Clang(trunk) treats 'non-inline namespace cannot be reopened as a inline' an error (correctly), but also complains 'inline namespace cannot be reopened as a non-inline namespace'. I'm curious why the latter should trigger a warning. G++ have no diagnostic for them at all.
I have a fix on the modules branch. Will commit in stage 1
Fixed by: 2017-05-15 Nathan Sidwell <nathan@acm.org> PR c++/79369 * cp-tree.h (DECL_NAMESPACE_INLINE_P): New. * name-lookup.h (push_namespace): Return int, add make_inline arg. * name-lookup.c (push_namespace): Deal with inline directly. Return pushed count. * parser.c (cp_parser_namespace_definition): Adjust for push_namespace change.