Skip to content

Commit 53ff130

Browse files
tst_Parser: replace Q_ASSERT(false) with Q_UNREACHABLE()
`Q_ASSERT()` disappears in release mode, leading Clang to print a static analysis warning about an impossible condition: ``` tst_parser.cpp:251:16: warning: variable 'err' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized] 251 | } else if (ourType == CborTextStringType) { | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ tst_parser.cpp:263:12: note: uninitialized use occurs here 263 | return err; | ^~~ tst_parser.cpp:251:12: note: remove the 'if' if its condition is always true ``` `Q_UNREACHABLE()` becomes a plain `__builtin_unreachable()` in release mode. Signed-off-by: Thiago Macieira <[email protected]>
1 parent 92a0252 commit 53ff130

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tests/parser/tst_parser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ CborError parseOneChunk(CborValue *it, QString *parsed)
258258
if (text)
259259
*parsed = '"' + QString::fromUtf8(text, len) + '"';
260260
} else {
261-
Q_ASSERT(false);
261+
Q_UNREACHABLE();
262262
}
263263
return err;
264264
}

0 commit comments

Comments
 (0)