public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug sanitizer/65081] New: -fsanitize=object-size fails with simple pointer arithm
@ 2015-02-16 18:22 larsbj at gullik dot net
  2015-02-16 18:28 ` [Bug sanitizer/65081] " redi at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: larsbj at gullik dot net @ 2015-02-16 18:22 UTC (permalink / raw)
  To: gcc-bugs

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.


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-02-18  9:47 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-16 18:22 [Bug sanitizer/65081] New: -fsanitize=object-size fails with simple pointer arithm larsbj at gullik dot net
2015-02-16 18:28 ` [Bug sanitizer/65081] " redi at gcc dot gnu.org
2015-02-17  9:39 ` mpolacek at gcc dot gnu.org
2015-02-17  9:49 ` mpolacek at gcc dot gnu.org
2015-02-17 10:38 ` jakub at gcc dot gnu.org
2015-02-17 10:46 ` mpolacek at gcc dot gnu.org
2015-02-18  9:47 ` mpolacek at gcc dot gnu.org
2015-02-18  9:47 ` mpolacek at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).