<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 - static_assert that is always false impossible?"
href="https://bugs.llvm.org/show_bug.cgi?id=46582">46582</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>static_assert that is always false impossible?
</td>
</tr>
<tr>
<th>Product</th>
<td>new-bugs
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</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>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>new bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>D.Bahadir@GMX.de
</td>
</tr>
<tr>
<th>CC</th>
<td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Reading <a href="https://devblogs.microsoft.com/oldnewthing/20200319-00/?p=103572">https://devblogs.microsoft.com/oldnewthing/20200319-00/?p=103572</a> I
assumed it should be possible to put a `static_assert` into a base-template
which is always `false` if instantiated.
The following is an example:
```c++
#include <type_traits>
template <typename T>
int square(T num)
{
static_assert(std::is_same_v<std::void_t<T>, int>, "FAILURE");
return num * num;
}
template <>
int square(double num)
{
return num * num;
}
void test()
{
//square(1); // Always fails.
square(1.0); // Should not fail but does in Clang.
}
```
Here, I am only calling the specialization of the template and in the
base-template `T` should be a dependent type that is not evaluated before
instantiation (due to `std::void_t`).
However, that only seems to be true for GCC but not Clang.
(See: <a href="https://godbolt.org/z/44zbae">https://godbolt.org/z/44zbae</a>)
Is that a bug in GCC or Clang?</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>