-fsanitize=undefined behavior

Segher Boessenkool segher@kernel.crashing.org
Fri May 1 13:38:23 GMT 2020


On Thu, Apr 30, 2020 at 10:57:49PM +0100, Jonathan Wakely via Gcc-help wrote:
> On Thu, 30 Apr 2020 at 22:27, Tom N <nospam@codesniffer.com> wrote:
> >
> > The man page for -fsanitize=undefined lists a bunch of sub-options (eg. -fsanitize=shift, -fsanitize=shift-exponent, etc).  If I include -fsanitize=undefined does it enable all of the sub-options, or none, or something in between?  If it doesn't enable all sub-options, is there an easy way to do that short of specifying all of them?
> The man page says:
> "Unlike other similar options, -fsanitize=float-divide-by-zero is not
> enabled by -fsanitize=undefined" and "Unlike other similar options,
> -fsanitize=float-cast-overflow is not enabled by -fsanitize=undefined"
> So it seems reasonable to assume that all the other suboptions are
> enabled by -fsanitize=undefined, and if you want *all* of them then
> use -fsanitize=undefined -fsanitize=float-divide-by-zero
> -fsanitize=float-cast-overflow

The code (flag-types.h) says
                                  | SANITIZE_BOUNDS_STRICT
(and there are no surprises with how it is used).  The
-fsanitize-bounds-strict option is unusual: it *weakens* what
-fsanitize-bounds does!

So yes, only -fsanitize=float-divide-by-zero and
-fsanitize=float-cast-overflow are not enabled by default.


More information about the Gcc-help mailing list