On Mon, 20 Feb 2023, Gabriel Ravier via Gcc-help wrote:
This is the kind of thing that makes me wonder why there isn't some kind of `__builtin_unreachable_do_not_optimize()` builtin that allows one to mark places in code that should never be reached and should thus be warned about if such a thing happens while at the same time never doing any optimization on the basis of the presence of the call.
-fsanitize=unreachable -fsanitize=null and others prevent the kind of optimization you are worried about.
-- Marc Glisse