[Bug middle-end/99578] [11/12 Regression] gcc-11 -Warray-bounds or -Wstringop-overread warning when accessing a pointer from integer literal
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Mar 17 10:49:01 GMT 2022
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99578
--- Comment #33 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Martin Sebor from comment #31)
> As I mentioned in comment #25 and elsewhere, I envisioned that code would
> annotate these hardwired addresses somehow, ideally using an attribute like
> addr or the Keil compiler's at (see below), or until one is added, using a
> workaround like your absolute_pointer(). I realize it means work, but I
> believe with the attribute the gain in type safety would make it worthwhile.
> Is that something the kernel developers could be trained to start using?
> (In full disclosure, I don't expect to have the cycles to work on the
> attribute anytime soon.)
Whether or not it's reasonable to expect working code to be transitioned to a
new feature, in the absence of such a feature (and no likelihood of it
appearing any time soon) we should not be giving warnings for this code.
The idea that it's zero-cost or zero-risk to go around sprinkling casts in
working code that passes all its tests is foolish. Every cast added to silence
a false positive warning has a risk of introducing a new problem and hiding a
real bug in future.
More information about the Gcc-bugs
mailing list