[Bug sanitizer/65081] New: -fsanitize=object-size fails with simple pointer arithm
larsbj at gullik dot net
gcc-bugzilla@gcc.gnu.org
Mon Feb 16 18:22:00 GMT 2015
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65081
Bug ID: 65081
Summary: -fsanitize=object-size fails with simple pointer
arithm
Product: gcc
Version: 5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: sanitizer
Assignee: unassigned at gcc dot gnu.org
Reporter: larsbj at gullik dot net
CC: dodji at gcc dot gnu.org, dvyukov at gcc dot gnu.org,
jakub at gcc dot gnu.org, kcc at gcc dot gnu.org
With:
gcc (GCC) 5.0.0 20150216 (experimental) as of 220738
and this test snippet:
-----------
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;
i->a = 1;
}
-----------
I get this report:
test.c:17:10: runtime error: store to address 0x0000006010a0 with insufficient
space for an object of type 'int'
0x0000006010a0: note: pointer points here
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00
^
When compiled like this:
gcc -O1 -fsanitize=object-size test.c
-fno-inline removes the runtime error, as do removing the pad_ from the intro
struct.
This is possibly an duplicate of bug 63303, but the errors are quite different.
More information about the Gcc-bugs
mailing list