https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87191

--- Comment #2 from Rich Felker <bugdal at aerifal dot cx> ---
This PR is about UBSan. I agree it's usually preferable to detect this type of
error statically by warnings, and I also filed #87192 for -Warray-bounds not
being able to catch the specific type of case I was affected by.

However, UB of this form is a dynamic condition at runtime, and any static
tests will have either false negatives or false positives, e.g. when the code
is reachable only conditionally on the size of the array and the conditional is
not locally visible.

In my case I tried UBSan as a fallback since I was surprised that no warning
was being generated, and when I found the UBSan also failed to catch the
problem, I reported this bug.

Reply via email to