[llvm-bugs] [Bug 48173] New: Increment incorrectly allowed for bool in requires-expressions
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Nov 13 09:40:13 PST 2020
https://bugs.llvm.org/show_bug.cgi?id=48173
Bug ID: 48173
Summary: Increment incorrectly allowed for bool in
requires-expressions
Product: clang
Version: trunk
Hardware: PC
OS: Windows NT
Status: NEW
Severity: enhancement
Priority: P
Component: C++2a
Assignee: unassignedclangbugs at nondot.org
Reporter: Casey at Carter.net
CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk
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" (https://godbolt.org/z/39xM1E) 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.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20201113/e4ba0915/attachment.html>
More information about the llvm-bugs
mailing list