Clang error: static assertion failed due to requirement 'A'... (err_static_assert_requirement_failed)
Jump to navigation
Jump to search
Text |
(since 15.0)
(6.0 - 14.0) | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Type | Error | ||||||||||
Category | Semantic Issue (since 6.0) | ||||||||||
Internal Id | err_static_assert_requirement_failed (since 6.0) | ||||||||||
Internal Message | static assertion failed due to requirement '%0'%select{: %2|}1 (since 15.0)static_assert failed due to requirement '%0'%select{ %2|}1 (6.0 - 14.0)
| ||||||||||
Regular Expression | (?:error|fatal error)\: static assertion failed due to requirement '(.*?)'(?:\: (.*?)|)
| ||||||||||
First Commit | 2017-09-15 672281a5116d Diagnostic specific failed condition in a static_assert. |
Description
Example
Flags | -xc++
|
|
---|---|---|
Source |
#include <type_traits>
static_assert(std::is_integral_v<float>, "float is not an integral type");
| |
Compiler Output |
<source>:3:15: error: static assertion failed due to requirement 'std::is_integral_v<float>': float is not an integral type |
Clang Internals (17.0.6)
Git Commit Message
Diagnostic specific failed condition in a static_assert. When a static_assert fails, dig out a specific condition to diagnose, using the same logic that we use to find the enable_if condition to diagnose. llvm-svn: 313315
Used in Clang Sources
This section lists all occurrences of the diagnostic within the Clang's codebase. For each occurrence, an auto-extracted snipped from the source code is listed including key elements like control structures, functions, or classes. It should illustrate the conditions under which the diagnostic is activated.
clang/lib/Sema/SemaDeclCXX.cpp (line 17149)
Decl *Sema::BuildStaticAssertDeclaration(SourceLocation StaticAssertLoc, Expr *AssertExpr, Expr *AssertMessage, SourceLocation RParenLoc, bool Failed) {
// ...
if (!AssertExpr->isTypeDependent() && !AssertExpr->isValueDependent() && (!AssertMessage || (!AssertMessage->isTypeDependent() && !AssertMessage->isValueDependent())) && !Failed) {
// ...
if (!Failed && !Cond && !InTemplateDefinition) {
// ...
if (InnerCond && isa<ConceptSpecializationExpr>(InnerCond)) {
// ...
} else if (InnerCond && !isa<CXXBoolLiteralExpr>(InnerCond) && !isa<IntegerLiteral>(InnerCond)) {
Diag(InnerCond->getBeginLoc(), diag::err_static_assert_requirement_failed) << InnerCondDescription << !HasMessage << Msg.str() << InnerCond->getSourceRange();
Triggered in Clang Tests
This section lists all internal Clang test cases that trigger the diagnostic.
clang/test/CXX/dcl.decl/dcl.meaning/dcl.array/p3.cpp
- clang/test/CXX/dcl.decl/dcl.meaning/dcl.array/p3.cpp:101:19: error: static assertion failed due to requirement 'sizeof (arr2) == 13':