3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2026-08-03 12:43:29 +00:00

Fix remaining clang warnings for fallthrough switch cases (in debug build). (#10314)

https://github.com/Z3Prover/z3/pull/10284 changed the UNREACHABLE macro
in debug.h to use __builtin_unreachable() to indicate to the compiler
that the
code leading it should be considered unreachable.

In https://github.com/Z3Prover/z3/pull/10295 Copilot figured out that
this was wrong: the unreachable macro makes calls, which shouldn't be
elided, and whose arguments should be evaluated. It partially fixed the
problem by declaring invoke_exit_action to be `[[noreturn]]`. This
eliminated warnings in non-debug builds, but when Z3_DEBUG is enabled,
`UNREACHABLE` ends with an invocation of `INVOKE_DEBUGER()`. This can
call `invoke_debugger()`, which *can* actually return (so it can't be
given the `[[noreturn]]` attribute. So we still get warnings in debug
builds.

This PR fixes those, creating a Z3_unreachable_case macro, which is just
a combination of `UNREACHABLE()` and `Z3_fallthrough`. It uses that in
the places that give warnings.

It seemed better to me to still have these cases have a single macro,
rather than `UNREACHABLE` followed by an explicit `Z3_fallthrough`; this
seemed to me like it would confuse people -- "how can you fall through
if this code is unreachable?" But I'm open to alternative suggestions!
This commit is contained in:
davedets 2026-07-30 19:24:46 -07:00 committed by GitHub
parent 141e99ffe7
commit c49eb07c3e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 11 additions and 5 deletions

View file

@ -780,7 +780,7 @@ namespace smt {
case OP_DISTINCT:
throw default_exception(std::string("formula has not been simplified") + " : " + mk_pp(n, m));
case OP_OEQ:
UNREACHABLE();
Z3_unreachable_case();
default:
break;
}