On Fri Nov 18 11:50:50 2022 +0000, Giovanni Mascellani wrote:
Yeah, in my intention `vkd3d_unreachable()` is equivalent to `assert(0)`, so it aborts with an error message without `NDEBUG` and it does nothing with `NDEBUG`, but with the difference that it lets the compiler knows (either via `__builtin_unreachable()` or via `__attribute__((noreturn))` that that piece of code is not meant to be reached (mostly so that the compiler spares us with its overzealous warnings without us sticking in dummy `return 0` statements; in theory there is also a performance gain, but I doubt that's ever going to be visible). I say that I don't see a real difference between violating an invariant by accident or by memory corruption because in practice I don't know how to differentiate between the two in advance.
After thinking about it I'm inclined to agree, there's not really any point in not using vkd3d_unreachable() for this.
I think part of my hesitation right now, honestly, is that vkd3d_unreachable() doesn't *look* like assert(), it looks like __builtin_unreachable(). Not sure I see a nice solution, though. I'd advocate for a vkd3d_assert(), but there's no nice way to mark that function as "might not return".