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

--- Comment #5 from Yichao Yu <yyc1992 at gmail dot com> ---
Yeah adding explicit bounds check do work but I still don't think the compiler
should be warning about this type of possible out-of-bound access.

FWIW, this code originate from a bigger project where the bounds check is
performed at a much higher level in a different compilation unit that the
compiler can't possibly see and in general I believe it's common for C/C++ code
to provide (especially internal) unsafe API. The OOB warning from compiler
should apply to cases where the compiler can see the input value (and it has
been really helpful in many cases) but not in all cases where a OOB access
"could" happen due to lack of information....

Reply via email to