mercredi 1 juin 2016

Using declaration refers into C, which is a base class (alias) of D, but it is not recognized as valid

This looks like an issue in clang (I've already opened a bug to clang), but I'd like to be sure that I'm not doing a mistake.

Consider the following code:

struct B { };

template<typename...>
struct D;

template<typename T, typename U, typename... A>
struct D<T, U, A...>: D<U, A...> {
    using C = D<U, A...>; // (1)
    // using D<U, A...>::D; // (2)
    // using C::C; // (3)
    using C::D; // (4)
};

template<typename T>
struct D<T>: T { using T::T; };

int main() {
    D<int, double, B> d{};
}

Lines (2) (if commented out (1) and (4)) and (3) (if commented out (4)) work as expected, while (1) (the example above as it is) gives the following errors:

11 : error: dependent using declaration resolved to type without 'typename'
using C::D;

[...]

11 : error: using declaration refers into 'C::', which is not a base class of 'D'
using C::D;

Anyway, C is an alias of D<U, A...>, that is a base class of D<T, U, A...>.
As far as I know, that snippet should compile. Am I wrong?

Note that GCC compiles it at least since v4.8.1 to v6.1.

Aucun commentaire:

Enregistrer un commentaire