<html>
<head>
<base href="http://llvm.org/bugs/" />
</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 --- - statement expressions do not evaluate as constexpr"
href="http://llvm.org/bugs/show_bug.cgi?id=16377">16377</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>statement expressions do not evaluate as constexpr
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</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>C++11
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>andyg1001@hotmail.co.uk
</td>
</tr>
<tr>
<th>CC</th>
<td>dgregor@apple.com, llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>The statement expressions extension under gcc permits its use in a constexpr
evaluation. So the following "dummy" code is accepted by gcc:
struct A { };
static_assert(({ 1; }), "oops");
constexpr auto a = ({ A(); });
And this macro which produces a useful diagnostic if used with a non-array
argument also works under gcc:
#define ARRAY_SIZEOF(A) \
({ static_assert(std::extent<__typeof__(A)>::value >= 0, \
TO_STRING(A) " is not an array with size >= 0"); \
std::extent<__typeof__(A)>::value; })
[[The TO_STRING macro isn't given, but it should be fairly clear what it
does!]]
clang unfortunately does not accept any of this code, complaining that it
doesn't constitute a constant expression. Would it be possible to extend clang
to support this?
Thanks.</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>