<p dir="ltr">On 7 Apr 2015 11:28 am, "Serge Pavlov" <<a href="mailto:sepavloff@gmail.com">sepavloff@gmail.com</a>> wrote:<br>
><br>
> 2015-04-07 2:23 GMT+06:00 Richard Smith <<a href="mailto:richard@metafoo.co.uk">richard@metafoo.co.uk</a>>:<br>
>><br>
>> ================<br>
>> Comment at: lib/Sema/SemaTemplateInstantiateDecl.cpp:4406-4407<br>
>> @@ +4405,4 @@<br>
>> +      const TagDecl *DeclToInstantiate = nullptr;<br>
>> +      if (TagDecl *Def = TD->getDefinition())<br>
>> +        DeclToInstantiate = Def;<br>
>> +      else if (!TD->isThisDeclarationADefinition() && !TD->isFreeStanding())<br>
>> ----------------<br>
>> What's the purpose of this change? If we have a reference to a particular `TagDecl`, why don't we always instantiate that declaration?<br>
>><br>
> If check for invalid declaration is made prior to this one, it seems that we can always instantiate the type.<br>
> This fix however allows to compile the following code:<br>
><br>
>   template<typename T> void f3() {<br>
>     struct AA {<br>
>       struct x3 vvv;<br>
>     } xx;<br>
>     return xx.aaa;<br>
>     struct x3 { int aaa; };<br>
>   }<br>
><br>
> It is because at the point where incomplete type is used we instantiate its definition, which is defined later.Strange, but gcc also compiles this code. Not sure why this code should be accepted.</p>
<p dir="ltr">That code is ill-formed; we should reject it.</p>
<p dir="ltr">> Thanks,<br>
> --Serge<br>
><br>
> _______________________________________________<br>
> cfe-commits mailing list<br>
> <a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
><br>
</p>