[cfe-dev] DR941

Richard Smith via cfe-dev cfe-dev at lists.llvm.org
Wed Feb 17 14:09:56 PST 2016


On Mon, Dec 21, 2015 at 6:50 PM, Nikola Smiljanic <popizdeh at gmail.com> wrote:
> So I'm looking at fixing this in Clang and after my naive approach failed I
> finally think I understand the issue at hand.
>
> When checking the explicit specialization Clang makes an implicit
> instantiation of the primary template. This happens inside the call to
> DeduceTemplateArguments. Existing declaration of the explicit template is
> then marked as a redeclaration of the newly created implicit instantiation.
>
> Interestingly the implicit instantiation is marked as deleted (because the
> primary template is) but the actual explicit specialization isn't.
>
> I came across David's fixme comment that mentions how we shouldn't be
> creating these implicit instantiations. So my question would be what's the
> right way to fix this? Not creating them at all, removing them at some
> point, replacing them with the actual explicit specialization or just trying
> to detect this pattern. Not creating them sounds best to me but I'm really
> lost as to how to achieve this. Help :)

Not creating them would be ideal. Most of the checks we perform on an
explicit specialization only need the implicitly instantiated
declaration's type, and not the instantiated declaration itself, and
most of the work required here will likely be changing the relevant
parts of Sema to take only a type rather than a FunctionDecl.

A simpler, but much less clean, alternative would be to strip off the
'deleted' flag when we create the explicit specialization, or to avoid
instantiating that part of the declaration if we know that we're
building an explicit specialization.



More information about the cfe-dev mailing list