[cfe-commits] [patch] Fix assert with explicit template specialization instantiation declarations followed by their definitions if the non-specialized template isn't defined

Nico Weber thakis at chromium.org
Fri Dec 23 13:01:53 PST 2011


I landed an alternative patch at r147225. I'd appreciate if someone
could take a look at that.

Nico

On Fri, Dec 23, 2011 at 11:18 AM, Nico Weber <thakis at chromium.org> wrote:
> Hi Hans & Enea,
>
> thanks for explaining the desired behavior to me, I think I get it now.
>
> I created a slightly more extensive test case (attached), and with
> that clang asserts with both proposed patches. I'll continue looking
> at this.
>
> Nico
>
> On Sat, Dec 17, 2011 at 6:55 AM, Hans Wennborg <hans at chromium.org> wrote:
>> On Sat, Dec 17, 2011 at 12:16 AM, Enea Zaffanella
>> <zaffanella at cs.unipr.it> wrote:
>>> Il 17/12/2011 00:57, Nico Weber ha scritto:
>>>> Hi,
>>>>
>>>> the attached patch fixes http://llvm.org/pr11558
>>>>
>>>> Ok?
>>>>
>>>> Nico
>>>
>>> I am not sure that setting a valid POI is really wanted when the
>>> explicit instantiation comes after an explicit specialization.
>>> Since the template is specialized, it is not instantiated.
>>> Hence, the late explicit instantiation(s) should have no effect.
>>> If this is correct, then the patch attached here is maybe worth a try
>>> (it passes all tests and seems to fix pr11558).
>>
>> I was digging into this on Friday as well, and I think Enea's approach
>> is the better one.
>>
>> As I understand, the explicit instantiation definition should have no
>> effect, because it's preceded by an explicit specialization
>> definition. The bug is that Clang doesn't handle this when there is an
>> explicit instantiation declaration (which itself has no effect for the
>> same reason) in between.
>>
>> The patch needs a test case, maybe just something like this:
>>
>> template <typename T> class MyClass {};
>> template <> class MyClass<char> {};
>> extern template class MyClass<char>;
>>
>> // Explicit instantiation declaration has no effect
>> // after explicit specialization definition.
>> template class MyClass<char>;
>>
>> I'm not template guru enough to sign off on this, though.
>>
>> Thanks,
>> Hans



More information about the cfe-commits mailing list