[Bug middle-end/77622] __builtin_object_size incorrect for an out-of-bounds pointer prior to destination object

tetra2005 at gmail dot com gcc-bugzilla@gcc.gnu.org
Sun Jan 22 18:08:00 GMT 2017


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

Yuri Gribov <tetra2005 at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org,
                   |                            |tetra2005 at gmail dot com

--- Comment #1 from Yuri Gribov <tetra2005 at gmail dot com> ---
Sounds like an important use-case. I did some basic debugging and it turns out
that "&d[3] - 10" is represented as POINTER_PLUS_EXPR with (size_t)-10 offset.
For some reason tree-object-size.c deliberately skips POINTER_PLUS_EXPRs with
offset > offset_limit where offset_limit is (size_t)-1 / 2 so negative offsets
are effectively ignored.

Added Jakub to maybe comment on this behavior as that's his code.


More information about the Gcc-bugs mailing list