<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 - Compile error for nested template alias"
href="https://bugs.llvm.org/show_bug.cgi?id=41062">41062</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Compile error for nested template alias
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>6.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++
</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, dgregor@apple.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>
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.</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>