<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - A bug for template specialization"
   href="https://bugs.llvm.org/show_bug.cgi?id=43496">43496</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>A bug for template specialization
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>8.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>C++17
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>liwei.cpp@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>blitzrakete@gmail.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The code is as follows:

#include <type_traits>

template <typename> class AddLayer;

template <template <typename> class TLayer>
struct LayerInputPortSet
{
    using type = int;
};

template <>
struct LayerInputPortSet<AddLayer>
{
    using type = float;
};

using type1 = typename LayerInputPortSet<AddLayer>::type;
static_assert(std::is_same_v<type1, float>);

template <template<typename> class TLayer>
struct Sublayer
{
    template <typename TInputs>
    using LayerType = TLayer<TInputs>;
};

using type = typename LayerInputPortSet<Sublayer<AddLayer>::template
LayerType>::type;
static_assert(std::is_same_v<type, float>);

When compiling (with -std=c++17), type1 == float, but with the introduction of
a wrapper (Sublayer), type != float. In fact, the compiler thought that type is
int. 

A similar issue is as follows:

#include <type_traits>

template <typename> class AddLayer;

template <template <typename> class TLayer>
struct LayerInputPortSet;

template <>
struct LayerInputPortSet<AddLayer>
{
    using type = float;
};

using type1 = typename LayerInputPortSet<AddLayer>::type;
static_assert(std::is_same_v<type1, float>);

template <template<typename> class TLayer>
struct Sublayer
{
    template <typename TInputs>
    using LayerType = TLayer<TInputs>;
};

using type = typename LayerInputPortSet<Sublayer<AddLayer>::template
LayerType>::type;
static_assert(std::is_same_v<type, float>);

When compiling, the compiler reports that 
implicit instantiation of undefined template
'LayerInputPortSet<Sublayer<AddLayer>::template LayerType>'

This bug happened on clang++ 6, 7, 8.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>