<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);">
Thank you.  That would appear to contradict C++11 14.7.1 paragraph 8 which said "The implicit instantiation of a class template does not cause any static data members of that class to be implicitly instantiated."  This paragraph seems to have expanded into
 C++17 17.8.1 paragraph 10, but still includes static data members.</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);">
Could you explain how this example does not violate that language?<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> David Blaikie <dblaikie@gmail.com><br>
<b>Sent:</b> Monday, September 23, 2019 11:23 AM<br>
<b>To:</b> Troy Johnson <troyj@cray.com><br>
<b>Cc:</b> cfe-dev@lists.llvm.org <cfe-dev@lists.llvm.org><br>
<b>Subject:</b> Re: [cfe-dev] unnecessary implicit instantiation?</font>
<div> </div>
</div>
<div>
<div dir="ltr">I believe the rules are that since 'M' is not dependent on any template parameters, it can be checked without deferring until the point of instantiation. (& that it isn't /required/ to be checked - it's up to the compiler, so both GCC and Clang
 are correct here)</div>
<br>
<div class="x_gmail_quote">
<div dir="ltr" class="x_gmail_attr">On Mon, Sep 23, 2019 at 8:07 AM Troy Johnson via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>> wrote:<br>
</div>
<blockquote class="x_gmail_quote" style="margin:0px 0px 0px 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex">
<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)">
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="x_gmail-m_-5586942480484149259appendonsend"></div>
<hr style="display:inline-block; width:98%">
<div id="x_gmail-m_-5586942480484149259divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> cfe-dev <<a href="mailto:cfe-dev-bounces@lists.llvm.org" target="_blank">cfe-dev-bounces@lists.llvm.org</a>>
 on behalf of Troy Johnson via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>><br>
<b>Sent:</b> Wednesday, September 18, 2019 4:26 PM<br>
<b>To:</b> <a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a> <<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>><br>
<b>Subject:</b> [cfe-dev] unnecessary implicit instantiation?</font>
<div> </div>
</div>
<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>
</div>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</blockquote>
</div>
</div>
</body>
</html>