This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug sanitizer/65081] -fsanitize=object-size fails with simple pointer arithm
- From: "mpolacek at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 17 Feb 2015 09:39:08 +0000
- Subject: [Bug sanitizer/65081] -fsanitize=object-size fails with simple pointer arithm
- Auto-submitted: auto-generated
- References: <bug-65081-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65081
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |mpolacek at gcc dot gnu.org
--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
-fno-inline removes the runtime error because __builtin_object_size then can't
determine the size of the object, and -fsanitize=object-size is dependent on
__bos.
E.g., run this slightly modified (printf line added) code:
struct intro
{
int a;
char pad_[1];
};
struct intro b;
struct intro *
alloc ()
{
struct intro *i = &b;
return i + 1;
}
int
main (void)
{
struct intro *i = alloc () - 1;
__builtin_printf ("%zd\n", __builtin_object_size (&i->a, 0));
i->a = 1;
}
$ xgcc -O e.c; ./a.out
8
$ xgcc -O e.c -fno-inline; ./a.out
-1
-1 means that __bos wasn't able to determine the size of an object.