[LLVMbugs] [Bug 19631] explicit specialization outside of template's namespace inaccuretly accepted

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri May 2 13:12:22 PDT 2014


http://llvm.org/bugs/show_bug.cgi?id=19631

Richard Smith <richard-llvm at metafoo.co.uk> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|---                         |INVALID

--- Comment #6 from Richard Smith <richard-llvm at metafoo.co.uk> ---
(In reply to comment #2)
> (In reply to comment #1)
> > Your quote from the standard shows that Clang is correct to accept this. The
> > specialization is in a namespace enclosing N. Since it's got a qualified
> > name, the second restriction does not apply.
> 
> You are reading it wrong, if we divide it sentence by sentence.

As the editor of the C++ standard, I generally like to think I know how to read
it. But maybe you're right. Let's see...

> 1. "An explicit specialization shall be declared in a namespace enclosing
>    the specialized template."
> 
>   This is what `clang` is violating.
[cut to corrected example] 
>     namespace N {
>       template<class> struct A { };
>       template<class> struct B { };
>     
>       template<> struct A<int>;
>     }
>     
>     template<> struct N::A<int> { }; // legal
>     template<> struct N::B<int> { }; // illegal, no declaration in the
>                                      // enclosing namespace of `N::A`

*This* declaration is an *a* namespace enclosing the specialized template. The
global namespace encloses it. See the definition of "enclosing namespaces" in
7.3.1/6; see also 7.3/2 if you don't believe that the global scope is a
namespace.

Also note that the rule says "declared in a namespace enclosing" not "declared
in the innermost enclosing namespace".

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140502/1c79b0c0/attachment.html>


More information about the llvm-bugs mailing list