Skip to content

[th/unreachable-asserts] improve asserts with (compile time) constant conditions and with NDEBUG/G_DISABLE_ASSERT

Thomas Haller requested to merge th/unreachable-asserts into main
  • if the condition to an assert is a compile time constant, handle that better

    • by letting NM_BOOLEAN_EXPR() return a constant expression too, so that the compiler sees the result.
  • if assertions are disabled with NDEBUG/G_DISABLE_ASSERT, still mark the failed assertion as __builtin_unreachable(). While we don't want to evalute the runtime check with assertions disabled (or call abort), we will still evaluate a compile time constant and tell the compiler that the code is unreachable.

Merge request reports