https://bugs.llvm.org/show_bug.cgi?id=41062

            Bug ID: 41062
           Summary: Compile error for nested template alias
           Product: clang
           Version: 6.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangb...@nondot.org
          Reporter: liwei....@gmail.com
                CC: blitzrak...@gmail.com, dgre...@apple.com,
                    erik.pilking...@gmail.com, llvm-bugs@lists.llvm.org,
                    richard-l...@metafoo.co.uk

// The code is as follows:

#include <type_traits>
using namespace std;

template <bool Add> struct Fun_;

template <>
struct Fun_<true> {
    template <typename T>
    using type = std::add_lvalue_reference<T>;
};

template <>
struct Fun_<false> {
    template <typename T>
    using type = std::remove_reference<T>;
};

template <typename T>
template <bool Add>
using Fun = typename Fun_<Add>::template type<T>;

template <typename T>
using Res_ = Fun<false>;

int main()
{
    Res_<int&>::type h = 3;
    return 0;
}

Gcc 7.3 could compile it, but clang 6.0 reports error as follows:

./main.cpp:20:1: error: extraneous template parameter list in alias template
declaration
using Fun = typename Fun_<Add>::template type<T>;
^
./main.cpp:23:18: error: template argument for template type parameter must be
a type
using Res_ = Fun<false>;
                 ^~~~~
./main.cpp:18:20: note: template parameter is declared here
template <typename T>
                   ^
./main.cpp:27:5: error: use of undeclared identifier 'Res_'
    Res_<int&>::type h = 3;
    ^
./main.cpp:27:13: error: expected '(' for function-style cast or type
construction
    Res_<int&>::type h = 3;
         ~~~^
./main.cpp:27:14: error: expected expression
    Res_<int&>::type h = 3;
             ^
./main.cpp:27:17: error: no member named 'type' in the global namespace
    Res_<int&>::type h = 3;
              ~~^
6 errors generated.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to