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. > Unfortunately santizer is only at runtime. I'm seeking build time warnings. Sharing my example: https://godbolt.org/z/c7b17nMGd Execution build compiler returned: 0 Program returned: 139 /app/example.cpp:4:10: runtime error: load of null pointer of type 'const char' Regards, Jonny