<div dir="ltr"><div dir="ltr">On Wed, 19 Feb 2020 at 17:56, Alexandre Isoard via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hi,</div><div><br></div>I'm having some issue with "opaque struct" being instantiated by Clang on unused reference arguments that have template types (that's an annoyance but not the topic of this email). I assume Clang decide to be lazy on the instantiation of unused arguments to save compile time.<div><br></div><div>But now I am wondering if that is actually a legal behavior in C++.</div><div>For example, the following code does not trigger the static_assert:<br><div><br></div><div><div style="color:rgb(0,0,0);background-color:rgb(255,255,254)"><div><span style="color:rgb(0,0,255)">template</span><<span style="color:rgb(0,0,255)">int</span> N></div><div><span style="color:rgb(0,0,255)">struct</span> test {</div><div>    <span style="color:rgb(0,0,255)">static_assert</span>(N == <span style="color:rgb(9,136,90)">42</span>);</div><div>};</div><br><div><span style="color:rgb(0,0,255)">int</span> foo(test<<span style="color:rgb(9,136,90)">69</span>> &a) {</div><div>    <span style="color:rgb(0,0,255)">return</span> <span style="color:rgb(9,136,90)">0</span>;</div><div>}</div></div><div><br></div><div>Is that expected/desired behavior? (if you add "a = a;" then it will properly trigger it)</div></div></div></div></blockquote><div><br></div><div>The C++ language rules do not permit instantiation of test<69> in this program. See <a href="http://eel.is/c++draft/temp.inst#1.sentence-1">http://eel.is/c++draft/temp.inst#1.sentence-1</a> -- this program does not require test<69> to be a complete type, and its definition doesn't affect the semantics of the program, so instantiation of that class is neither required nor permitted here. </div></div></div>