<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 - Clangs 4 through 7 panic on non-const expressions inside the ctrl-expr of _Generic's where only the final value needs to be constant"
href="https://bugs.llvm.org/show_bug.cgi?id=40666">40666</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Clangs 4 through 7 panic on non-const expressions inside the ctrl-expr of _Generic's where only the final value needs to be constant
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>4.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>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Frontend
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>pskocik@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>The code below demonstrates the problem:
#define MC_cexpr_eh_(X) _Generic((1? (void *) ((!!(X))*0ll) : (int *) 0), int*:
1, void*: 0)
extern int i;
#if 1 //FAILS:
_Bool const fail0 = MC_cexpr_eh_((int){i});
void fail() { enum { fail1 = MC_cexpr_eh_( (int){i}) }; }
#endif
//THESE WORK:
void ok()
{
enum { ok0 = MC_cexpr_eh_( i ) };
const _Bool ok1 = MC_cexpr_eh_( (int){i});
static _Bool const ok2 = MC_cexpr_eh_((int){i});
}
I don't think the comptime (non)constness of the controlling expression of a
_Generic should ever matter.
gcc and tinycc are doing this right.</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>