<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
Clang issues an error for the following code, whereas the GNU compiler does not.  Based on the standard, I think that an implicit instantiation should not occur because the compiler is not yet allocating an object, and that would mean that Clang is incorrectly
 issuing an error and GNU is correct to not issue any error.<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
Is my understanding correct?<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<span>> cat t.cpp<br>
</span>
<div>template <typename T> class A;<br>
</div>
<div><br>
</div>
<div>template <typename T><br>
</div>
<div>struct B {<br>
</div>
<div>  static A<int> M;<br>
</div>
<div>};<br>
</div>
<div><br>
</div>
<div>template <typename T> A<int> B<T>::M;<br>
</div>
<div>> g++ -c t.cpp<br>
</div>
<div>> clang -c t.cpp<br>
</div>
t.cpp:8:36: error: implicit instantiation of undefined template 'A<int>'<br>
<div>template <typename T> A<int> B<T>::M;<br>
</div>
<div>                                   ^<br>
</div>
<div>t.cpp:1:29: note: template is declared here<br>
</div>
<div>template <typename T> class A;<br>
</div>
<div>                            ^<br>
</div>
<span>1 warning and 1 error generated.</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
Thanks,</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
Troy<br>
</div>
</body>
</html>