-
Notifications
You must be signed in to change notification settings - Fork 15.1k
Closed
Labels
bugzillaIssues migrated from bugzillaIssues migrated from bugzillac++17c++20clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerconfirmedVerified by a second partyVerified by a second party
Description
Bugzilla Link | 48173 |
Version | trunk |
OS | All |
CC | @Quuxplusone,@zygoloid |
Extended Description
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.
Metadata
Metadata
Assignees
Labels
bugzillaIssues migrated from bugzillaIssues migrated from bugzillac++17c++20clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerconfirmedVerified by a second partyVerified by a second party
Type
Projects
Status
Done