[llvm-bugs] [Bug 43496] New: A bug for template specialization
via llvm-bugs
llvm-bugs at lists.llvm.org
Sat Sep 28 23:09:27 PDT 2019
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: unassignedclangbugs at nondot.org
Reporter: liwei.cpp at gmail.com
CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190929/0a39d298/attachment-0001.html>
More information about the llvm-bugs
mailing list