https://bugs.llvm.org/show_bug.cgi?id=42523

            Bug ID: 42523
           Summary: Non-inline unnamed namespaces can be redeclared as
                    inline in some cases
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected], [email protected],
                    [email protected]

The following code is correctly rejected:

inline namespace I {
    namespace N {}
    using namespace N;
    namespace N { int i; }
}
inline namespace N { }

Clang produces the following diagnostic:
<source>:6:18: error: non-inline namespace cannot be reopened as inline
inline namespace N { }
                 ^
<source>:4:15: note: previous definition is here
    namespace N { int i; }
              ^
1 error generated.
Compiler returned: 1

But this code is accepted:

inline namespace I {
    namespace { int i; }
}
inline namespace { }

According to the standard ([namespace.unnamed]/1), An
unnamed-namespace-definition behaves as if it were replaced by

    inline_opt 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.

I.e. the second example should also be rejected.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to