std::string add nullptr attribute
Segher Boessenkool
segher@kernel.crashing.org
Mon Feb 20 11:28:38 GMT 2023
On Mon, Feb 20, 2023 at 12:18:36PM +0100, Marc Glisse via Gcc-help 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.
Or even just __builtin_trap(), or abort(), or similar. Just a printf()
thing if you really want to just warn.
"Never doing any optimisation" based on <anything> is of course not a
reasonable expectation; but you *can* ask for reachable code not to be
optimised away. This is the default, just don't mark reachable code as
unreachable :-)
Segher
More information about the Gcc-help
mailing list