Issue 81019
Summary Explicit template instantiation rejected when the template is found via `using namespace`
Labels new issue
Assignees
Reporter abbeyj
    The following code is accepted by GCC, ICC, and MSVC but is rejected by clang with the error `error: explicit instantiation of 'N::C' must occur in namespace 'N'`.

```C++
namespace N {
 template <typename T>
    class C {
    };
}

using namespace N;

template class C<int>;
```

It is my understanding that rejecting this code used to be the correct behavior according to the standard.  See https://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#275 , specifically "If the name declared in the explicit instantiation is an unqualified name, the explicit instantiation shall appear in the namespace where its template is declared."

However this language was eventually removed by https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p1787r6.html which is going to be part of C++23.

See also #54150 

https://godbolt.org/z/KMY7Me9Es



_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to