https://bugs.llvm.org/show_bug.cgi?id=43496
Bug ID: 43496
Summary: A bug for template specialization
Product: clang
Version: 8.0
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: C++17
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected],
[email protected], [email protected]
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.
--
You are receiving this mail because:
You are on the CC list for the bug._______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs