llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
27.84k stars 11.47k forks source link

Passing template alias as template template parameter causes specialization matching to fail #26467

Open llvmbot opened 8 years ago

llvmbot commented 8 years ago
Bugzilla Link 26093
Version 3.7
OS Linux
Reporter LLVM Bugzilla Contributor
CC @DougGregor,@zygoloid,@SuperV1234

Extended Description

Hi, here is example of code which I believe valid, compiles using gcc-4.9.3 but fails to compile with clang-3.5.2, clang-3.6.2 and 3.7.0.

template<bool val> struct bool_type
{
      static constexpr bool value = val;
};

template<typename T, template<typename...> class Template>
struct inst_of : bool_type<false> {};

template<template<typename...> class Template, typename... Params>
struct inst_of<Template<Params...>, Template> : bool_type<true> {};

template<typename X>
struct some_templ;

template<typename X>
using some_alias = some_templ<X>;

static_assert(inst_of<some_templ<int>, some_templ>::value, "");//ok
static_assert(inst_of<some_alias<int>, some_templ>::value, "");//ok
static_assert(inst_of<some_alias<int>, some_alias>::value, "");//assert
static_assert(inst_of<some_templ<int>, some_alias>::value, "");//assert

//some more tests
template<typename T>
struct inst_of_some_templ : bool_type<false> {};
template<typename T>
struct inst_of_some_templ<some_templ<T>> : bool_type<true> {};

template<typename T>
struct inst_of_some_alias : bool_type<false> {};
template<typename T>
struct inst_of_some_alias<some_alias<T>> : bool_type<true> {};

static_assert(inst_of_some_templ<some_templ<int>>::value, "");//ok
static_assert(inst_of_some_templ<some_alias<int>>::value, "");//ok
static_assert(inst_of_some_alias<some_alias<int>>::value, "");//ok
static_assert(inst_of_some_alias<some_templ<int>>::value, "");//ok
llvmbot commented 7 years ago

This looks like a dup of #​18411 to me.

vittorioromeo commented 7 years ago

Still occurs in 4.0 SVN. Possibly related issue/example: http://stackoverflow.com/questions/40840734