<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<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);">
If there's a different email list for C++ language questions like this, please let me know, since I'm trying establish which compiler's behavior is correct before I try to change anything in Clang.  The standard is a little fuzzy on this matter because it says
 that the instantiation occurs as needed, and one could argue that one does not need to know the size of a static data member in order to use the class type as part of another definition.  Clang seems to want the whole definition of the class, including static
 data, to be fully defined before using it.<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);">
-Troy<br>
</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> cfe-dev <cfe-dev-bounces@lists.llvm.org> on behalf of Troy Johnson via cfe-dev <cfe-dev@lists.llvm.org><br>
<b>Sent:</b> Wednesday, September 18, 2019 4:26 PM<br>
<b>To:</b> cfe-dev@lists.llvm.org <cfe-dev@lists.llvm.org><br>
<b>Subject:</b> [cfe-dev] unnecessary implicit instantiation?</font>
<div> </div>
</div>
<style type="text/css" style="display:none">
<!--
p
        {margin-top:0;
        margin-bottom:0}
-->
</style>
<div 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>
</div>
</body>
</html>