On Thu, Jan 28, 2021 at 6:04 PM Martin Sebor via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> The GCC 11 -Warray-bounds enhancement to diagnose accesses whose
> leading offset is in bounds but whose trailing offset is not has
> been causing some confusion.  When the warning is issued for
> an access to an in-bounds member via a pointer to a struct that's
> larger than the pointed-to object, phrasing this strictly invalid
> access in terms of array subscripts can be misleading, especially
> when the source code doesn't involve any arrays or indexing.
>
> Since the problem boils down to an aliasing violation much more
> so than an actual out-of-bounds access, the attached patch adjusts
> the code to issue a -Wstrict-aliasing warning in these cases instead
> of -Warray-bounds.  In addition, since the aliasing assumptions in
> GCC can be disabled by -fno-strict-aliasing, the patch also makes
> these instances of the warning conditional on -fstrict-aliasing
> being in effect.
>
> Martin

-Wstrict-aliasing is a warning with numerical levels; can you clarify
which of them this is active at?
(also I have always found it confusing how -Wstrict-aliasing's
numerical levels are in reverse order from most other warnings with
numerical levels; i.e., how higher numbers supposedly mean fewer
warnings for it (according to documentation) rather than more, as is
the case with most other warnings with numerical levels)

Reply via email to