Template parameters not deducible in partial specialization in gcc6, for a case that used to work in gcc5

Viewed 3301

This code results in an error in gcc6 (but works fine in gcc 4.8, 5.2 and clang 3.6):

template <typename T>
struct outer
{
    template <typename U>
    struct inner
    {

    };
};


template <typename T>
struct is_inner_for
{

    template <typename Whatever>
    struct predicate
    {
        static constexpr bool value = false;
    };

    template <typename U>
    struct predicate<typename outer<T>::template inner<U>>
    {
        static constexpr bool value = true;
    };
};

static_assert(
    is_inner_for<int>::template predicate<
        outer<int>::inner<double>
    >::value,
    "Yay!"
);

The error is:

main.cpp:22:9: error: template parameters not deducible in partial specialization:
  struct predicate<typename outer<T>::template inner<U>> : std::true_type
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:22:9: note:         'U'
 ^~~~~~~~~~~~~

Commandline is:

g++ -std=c++1y -c main.cpp

See godbolt output here.

I have filed a bug report with gcc here: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70141

However it was marked as invalid (I believe wrongly). The outer<T> that is used inside predicate is a concrete type at that point, so it is not a non-deduced context.

Is there anything in the standard that prevents this being valid c++ code?

1 Answers
Related