On 20/02/2023 11:18, Marc Glisse wrote: > 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. > Santizer is roughly 2-4x slower, but for simple applications that may be fine. https://developers.redhat.com/blog/2021/05/05/memory-error-checking-in-c-and-c-comparing-sanitizers-and-valgrind Jonny