by wglb on 8/7/25, 3:20 PM with 14 comments
by tylerhou on 8/11/25, 2:30 AM
This would prevent the last bug (!ua()) as the control flow sensitive analysis can reason about both branches: that it is invalid to deref ua within the block. The dynamic check misses the bug because the branch is never taken for the given inputs.
I am fairly confident that the clang-tidy pass is simpler and more precise in most cases than the hand-rolled implementation. (That said the static check may not be able to reason about mutation well.)
If you need to pass an error in the failure case, you can use std::expected (available in C++23). clang-tidy has an open bug about supporting a similar check for std::expected: https://github.com/llvm/llvm-project/issues/135045
by mananaysiempre on 8/11/25, 1:51 AM
if (int x = foo(); x) { ... }
nor the C++98 syntax if (int x = foo()) { ... }
is supported in C99, it still introduces the rule that the entire if statement is a scope (which it wasn’t in C89). So as a party trick, here’s a way to check for C99 without using the preprocessor: int c99() {
enum { C99 = 1 };
{
if (sizeof(enum { C99 = 0 })) { }
return C99;
}
}
I make no promises about the behaviour of this code on insufficiently anal compilers like TCC.by rerdavies on 8/11/25, 6:08 AM
If you use github release workflow, you don't even have a choice about it. You cannot create a release without creating a matching tag.
by themafia on 8/11/25, 4:45 AM
You may very well be able to ditch colors using this technique with additional characters. Many characters are distinct with their inverted counterpart.