Skip to content

Commit

Permalink
tst_Parser: replace Q_ASSERT(false) with Q_UNREACHABLE()
Browse files Browse the repository at this point in the history
`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]>
  • Loading branch information
thiagomacieira committed Feb 14, 2025
1 parent 92a0252 commit 53ff130
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tests/parser/tst_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ CborError parseOneChunk(CborValue *it, QString *parsed)
if (text)
*parsed = '"' + QString::fromUtf8(text, len) + '"';
} else {
Q_ASSERT(false);
Q_UNREACHABLE();
}
return err;
}
Expand Down

0 comments on commit 53ff130

Please sign in to comment.