[cfe-dev] crash with explicit instantiation (PR24629)
don hinton via cfe-dev
cfe-dev at lists.llvm.org
Fri Feb 12 14:55:52 PST 2016
Submitted http://reviews.llvm.org/D17215
On Thu, Feb 11, 2016 at 4:46 PM, don hinton <hintonda at gmail.com> wrote:
> The following code will crash the clang:
>
> template<class T>
> struct X {
> void bar(T t) {}
> void foo(T t, int i) {}
>
> template<class U>
> void foo(T t, U i) {}
> };
>
> template class X<double>;
> template void X<double>::bar(double t); // error, reports duplicate
>
> template void X<double>::foo(double t, int i); // crashes, but should
> report duplicate
>
> template void X<double>::foo<int>(double t, int i); // crashes, but
> should be okay
>
>
> The error for bar() is correct, since it was already explicitly
> instantiated by X, however, I believe the first, non-templatized, version
> of foo() should have the same behavior, but it crashes, as does the
> templatized version.
>
> But if I just use them without explicit instantiation, they work as
> expected, e.g.:
>
> X<double> x;
> x.bar(1.2);
> x.foo(1.2, 1);
> x.foo<int>(1.2, 1);
>
> With the non-templatized version of foo() taking precidence.
>
> Before I make a run at fixing this, I just wanted to make sure I was doing
> the right thing.
>
> thanks...
> don
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160212/a7226b79/attachment.html>
More information about the cfe-dev
mailing list