• Stephan Bergmann's avatar
    Introduce O3TL_UNREACHABLE as a better alternative to assert(false) · 9935a831
    Stephan Bergmann yazdı
    The code in sw/source/core/fields/reffld.cxx had turned into whack-a-mole:  MSVC
    needed the unreachable default:assert(false); to fall through to init some vars
    to avoid C4701 ("potentially uninitialized local variable").  But Clang (with
    !NDEBUG, and an implementation of assert marked as noreturn) reported that as
    "fallthrough annotation in unreachable code", requiring the #ifdef NDEBUG guards
    to be added.  And now clang-cl (also with !NDEBUG, but with the MSVC
    implementation of assert apparently not marked as noreturn) complained about
    "unannotated fall-through between switch labels", which wold require the #ifdef
    NDEBUG guards to be removed again.
    O3TL_UNREACHABLE (inspired by LLVM's llvm_unreachable and underyling
    LLVM_BUILTIN_UNREACHABLE) hopefully improves on that for all compilers involved.
    For non-MSVC (i.e., Clang or GCC) it assumes that __builtin_unreachable is
    supported (which it is at least for GCC 7, which is our current baseline per
    Change-Id: I4474f95664d97c3d0e506bab90f80d5ab252ec6e
    Reviewed-on: https://gerrit.libreoffice.org/67232
    Tested-by: Jenkins
    Reviewed-by: 's avatarStephan Bergmann <sbergman@redhat.com>
unreachable.hxx 1.75 KB