Skip to content

Explicit template instantiation of nested types #48477

@Tomaqa

Description

@Tomaqa
Bugzilla Link 49133
Version 11.0
OS Linux
CC @dwblaikie,@DougGregor,@zygoloid

Extended Description

Clang does not accept explicit class template instantiation of a nested type.

Minimal example:

template <typename>
struct Tp {
    using Alias = Tp;
};

/// All should be valid and equivalent
extern template struct Tp<int>;             //< works
extern template struct Tp<int>::Tp;         //< fails
extern template struct Tp<int>::Alias::Tp;  //< fails
error: explicit instantiation of non-templated type 'Tp<int>'

The inst. of nested types should be standard-compliant as well as the first one.
Also, the error message is quite confusing.
Works in GCC.

https://stackoverflow.com/questions/34506356/using-typedef-in-template-instantiation-and-extern-template-declaration/34506955#34506955
https://stackoverflow.com/questions/11414817/code-duplication-between-typedefs-and-explicit-instantiations

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillac++11clang:frontendLanguage frontend issues, e.g. anything involving "Sema"diverges-from:edgDoes the clang frontend diverge from edg compiler on this issuediverges-from:gccDoes the clang frontend diverge from gcc on this issuediverges-from:msvcDoes the clang frontend diverge from msvc on this issuewaiting-for-wg21Blocked on C++ Standards Committee

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions