[llvm-bugs] [Bug 38205] New: type mismatch in explicit template instantiate not detected

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Jul 17 19:37:37 PDT 2018


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

            Bug ID: 38205
           Summary: type mismatch in explicit template instantiate not
                    detected
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: zhonghao at pku.org.cn
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org

The code is as follow:

template<class T>
class A
{
 static T a;
};

template<class T>
T A<T>::a;

class B
{ };

template
int A<B>::a; // type mismatch

clang++ accepts the code. The code should produce an error for the explicit
template instantiation, because the type given for the static variable
doesn't match the one in the class template. Please note that g++ rejects the
code:

error: type 'B' for explicit instantiation 'A<B>::a' does not match declared
type 'int'
 int A<B>::a; // type mismatch

-- 
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/20180718/9f023965/attachment.html>


More information about the llvm-bugs mailing list