https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70141

            Bug ID: 70141
           Summary: [6.0 regression] template parameter not deducible in
                    partial specialization of template inside template
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: kholdstare0.0 at gmail dot com
  Target Milestone: ---

Created attachment 37899
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=37899&action=edit
Preprocessed source

The code below works on gcc 4.8, 5.2, and clang 3.6, but fails to compile on
gcc 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 commandline:

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

Here is the error:

        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'
        main.cpp:26:1: error: static assertion failed: Yay!
         static_assert(
         ^~~~~~~~~~~~~

Another thing I noticed is that *I get the error even if I don't use the
"is_inner_for" template*. It looks like some rule that gets applied before
template instantiation - maybe it's too strict...

Reply via email to