<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 - ICE on valid, templated friend injection cause ICE, invalid template parameters, true and false at the same time assert condition"
href="https://bugs.llvm.org/show_bug.cgi?id=50989">50989</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>ICE on valid, templated friend injection cause ICE, invalid template parameters, true and false at the same time assert condition
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>8.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>All
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</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>bastienPenava@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>Hi,
I've stumbled upon a really weird bug with how friends are handled by clang.
The following causes invalid template parameters to be introduced and an ICE.
It's present since clang 8.0 and is still present in trunk.
Befoer clang 8, the friend was just never instantiated, which was also invalid.
Here a compiler-explorer link to the issue: <a href="https://godbolt.org/z/qzM41rrKG">https://godbolt.org/z/qzM41rrKG</a>
Or here, the a minimal example:
```
#include <type_traits>
template<class...> struct type_t {};
struct A {};
template<class... Args>
void fn(A, type_t<Args...>);
template<int N>
void nothing() {}
struct fn_arg {};
struct class_arg {};
template<class T>
struct B
{
template<class... Args>
friend void fn(A, type_t<Args...>) {
static_assert(std::is_same<T, fn_arg>::value, "Should be class_arg!");
static_assert(sizeof...(Args) != 0, "ok");
static_assert(sizeof...(Args) == 0, "What?");
constexpr auto n = sizeof...(Args);
nothing<n>(); //ICE!
}
};
void func(B<class_arg> = {}) {}
int main()
{
fn(A{}, type_t<fn_arg>{});
}
```
Thanks in advance</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>