[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 11:18:38 PST 2011


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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tmp.cc
Type: application/octet-stream
Size: 3151 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20111223/d11f39eb/attachment.obj>


More information about the cfe-commits mailing list