On 7 Apr 2015 11:28 am, "Serge Pavlov" <[email protected]> wrote:
>
> 2015-04-07 2:23 GMT+06:00 Richard Smith <[email protected]>:
>>
>> ================
>> Comment at: lib/Sema/SemaTemplateInstantiateDecl.cpp:4406-4407
>> @@ +4405,4 @@
>> +      const TagDecl *DeclToInstantiate = nullptr;
>> +      if (TagDecl *Def = TD->getDefinition())
>> +        DeclToInstantiate = Def;
>> +      else if (!TD->isThisDeclarationADefinition() &&
!TD->isFreeStanding())
>> ----------------
>> What's the purpose of this change? If we have a reference to a
particular `TagDecl`, why don't we always instantiate that declaration?
>>
> If check for invalid declaration is made prior to this one, it seems that
we can always instantiate the type.
> This fix however allows to compile the following code:
>
>   template<typename T> void f3() {
>     struct AA {
>       struct x3 vvv;
>     } xx;
>     return xx.aaa;
>     struct x3 { int aaa; };
>   }
>
> 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.

That code is ill-formed; we should reject it.

> Thanks,
> --Serge
>
> _______________________________________________
> cfe-commits mailing list
> [email protected]
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to