public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/97027] New: missing warning on buffer overflow storing a larger scalar into a smaller array
@ 2020-09-11 21:10 msebor at gcc dot gnu.org
  2020-10-13 16:53 ` [Bug middle-end/97027] " msebor at gcc dot gnu.org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: msebor at gcc dot gnu.org @ 2020-09-11 21:10 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 97027
           Summary: missing warning on buffer overflow storing a larger
                    scalar into a smaller array
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gcc dot gnu.org
  Target Milestone: ---

None of the obviously out-of-bounds stores in the functions below is diagnosed.
 They all should and easily could be.

typedef __INT64_TYPE__ int64_t;
typedef __attribute__ ((__vector_size__ (8))) char V8;
typedef __attribute__ ((__vector_size__ (64))) char V64;

void f0 (int i)
{
  char a[1];
  void *p = a;
  *(int64_t*)p = i;   // storing 8 bytes into a one-byte array
  __builtin_puts (a);
}

void f1 (int i)
{
  char a[1];
  if (i < 1 || 2 < i) i = 1;
  void *p = a + i;
  *(int64_t*)p = i;   // storing 8 bytes at offset 1 into a one-byte array
  __builtin_puts (a);
}

void g0 (int i)
{
  char a[1];
  void *p = a;
  *(V8*)p = (V8){ i };   // storing 8 bytes into a one-byte array
  __builtin_puts (a);
}

void g1 (int i)
{
  char a[1];
  if (i < 1 || 2 < i) i = 1;
  void *p = a + i;
  *(V64*)p = (V64){ i };   // storing 64 bytes at offset 1 into a one-byte
array
  __builtin_puts (a);
}

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

end of thread, other threads:[~2021-07-15 19:22 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-11 21:10 [Bug middle-end/97027] New: missing warning on buffer overflow storing a larger scalar into a smaller array msebor at gcc dot gnu.org
2020-10-13 16:53 ` [Bug middle-end/97027] " msebor at gcc dot gnu.org
2020-10-13 16:55 ` msebor at gcc dot gnu.org
2020-10-13 19:07 ` msebor at gcc dot gnu.org
2021-07-07 20:14 ` cvs-commit at gcc dot gnu.org
2021-07-07 20:30 ` msebor at gcc dot gnu.org
2021-07-09 17:38 ` msebor at gcc dot gnu.org
2021-07-09 17:54 ` msebor at gcc dot gnu.org
2021-07-13 19:27 ` msebor at gcc dot gnu.org
2021-07-13 19:27 ` msebor at gcc dot gnu.org
2021-07-15  9:22 ` clyon at gcc dot gnu.org
2021-07-15 19:16 ` cvs-commit at gcc dot gnu.org
2021-07-15 19:22 ` msebor 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).