[cfe-commits] [patch] Fix assert with explicit template specialization instantiation declarations followed by their definitions if the non-specialized template isn't defined
Hans Wennborg
hans at chromium.org
Sat Dec 17 06:55:34 PST 2011
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