[Bug middle-end/97027] missing warning on buffer overflow storing a larger scalar into a smaller array

msebor at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Jul 9 17:38:38 GMT 2021


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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|FIXED                       |---

--- Comment #6 from Martin Sebor <msebor at gcc dot gnu.org> ---
Still not completely fixed.  gcc.dg/Wstringop-overflow-47.c still fails on
aarch64 due to the different IL.  The test below (extracted from
Wstringop-overflow-47.c) is diagnosed as expected with an x86_64 native GCC but
now with an aarch64 cross.

$ cat t.c && /build/aarch64-linux/gcc-master/gcc/xgcc -B
/build/aarch64-linux/gcc-master/gcc -O2 -S -fdump-tree-optimized=/dev/stdout
t.c
typedef __INT16_TYPE__                         int16_t;
typedef __attribute__ ((__vector_size__ (32))) char C32;

void warn_c32 (char c)
{
  extern char warn_a32[32];   // { dg-message "at offset 32 into destination
object 'warn_a32' of size 32" "pr97027" }

  void *p = warn_a32 + 1;
  *(C32*)p = (C32){ c };      // { dg-warning "writing 1 byte into a region of
size 0" "pr97027" }
}

;; Function warn_c32 (warn_c32, funcdef_no=0, decl_uid=3908, cgraph_uid=1,
symbol_order=0)

void warn_c32 (char c)
{
  vector(32) char _1;

  <bb 2> [local count: 1073741824]:
  _1 = {c_2(D)};
  MEM[(C32 *)&warn_a32 + 1B] = _1;
  return;

}


More information about the Gcc-bugs mailing list