<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 - Increment incorrectly allowed for bool in requires-expressions"
href="https://bugs.llvm.org/show_bug.cgi?id=48173">48173</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Increment incorrectly allowed for bool in requires-expressions
</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>Windows NT
</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++2a
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>Casey@Carter.net
</td>
</tr>
<tr>
<th>CC</th>
<td>blitzrakete@gmail.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>Compiling this well-formed program:
template <class T>
concept can_increment = requires(T t) {
++t;
};
template <class T>
void f() {
static_assert(requires(T t) { ++t; }); // Incorrectly allowed
}
int main() {
f<bool>();
static_assert(!can_increment<bool>); // Incorrectly fails
bool b = false;
++b; // Correctly rejected
}
with "clang++ -std=c++2a" (<a href="https://godbolt.org/z/39xM1E">https://godbolt.org/z/39xM1E</a>) diagnoses:
<source>:14:5: error: static_assert failed due to requirement
'!can_increment<bool>'
static_assert(!can_increment<bool>); // Incorrectly fails
^ ~~~~~~~~~~~~~~~~~~~~
<source>:17:5: error: ISO C++17 does not allow incrementing expression of
type bool [-Wincrement-bool]
++b;
^ ~
The compiler knows that the language forbids increment of bools _outside_ a
requires-expression, but apparently not _within_ a requires-expression.</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>