public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/96963] New: -Wstringop-overflow false positive on -O3 or -O2 -ftree-vectorize when assigning consecutive char struct members
@ 2020-09-07 20:46 gcc_bugzilla at venus dot thegavinli.com
  2020-09-07 23:15 ` [Bug tree-optimization/96963] " msebor at gcc dot gnu.org
                   ` (18 more replies)
  0 siblings, 19 replies; 20+ messages in thread
From: gcc_bugzilla at venus dot thegavinli.com @ 2020-09-07 20:46 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 96963
           Summary: -Wstringop-overflow false positive on -O3 or -O2
                    -ftree-vectorize when assigning consecutive char
                    struct members
           Product: gcc
           Version: 10.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gcc_bugzilla at venus dot thegavinli.com
  Target Milestone: ---

Created attachment 49194
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49194&action=edit
Test case that triggers bug

Versions affected: 10.2.0 and git master (commit 703bc188f4)

System type: both x86_64-pc-linux-gnu and arm-none-eabi affected

Compilation flags: I tested a couple compilers with the same result:
1) Arch Linux toolchain, configured with: /build/gcc/src/gcc/configure
--prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man
--infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/
--enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++,d --with-isl
--with-linker-hash-style=gnu --with-system-zlib --enable-__cxa_atexit
--enable-cet=auto --enable-checking=release --enable-clocale=gnu
--enable-default-pie --enable-default-ssp --enable-gnu-indirect-function
--enable-gnu-unique-object --enable-install-libiberty --enable-linker-build-id
--enable-lto --enable-multilib --enable-plugin --enable-shared
--enable-threads=posix --disable-libssp --disable-libstdcxx-pch
--disable-libunwind-exceptions --disable-werror
gdc_include_dir=/usr/include/dlang/gdc
2) Built from git, configured with: ./configure --prefix=/tmp/gcc-master
--disable-multilib

Command lines that trigger bug:
    $ gcc sample.c -c -O3
    $ gcc sample.c -c -O2 -ftree-vectorize

Code that triggers bug:

    struct foo {
        int i;
        char a;
        char b;
    };

    void heh(char *);

    void clr(struct foo *f) {
        heh(&f->a);
        f->a = 0;
        f->b = 0;
    }

Output of compiler:

    sample.c: In function ‘clr’:
    sample.c:11:10: warning: writing 2 bytes into a region of size 1
[-Wstringop-overflow=]
       11 |     f->a = 0;
          |     ~~~~~^~~
    sample.c:3:10: note: at offset 0 to object ‘a’ with size 1 declared here
        3 |     char a;
          |          ^

-fdump-tree-optimized:

    ;; Function clr (clr, funcdef_no=0, decl_uid=1936, cgraph_uid=1,
symbol_order=0)

    clr (struct foo * f)
    {
      char * _1;

      <bb 2> [local count: 1073741824]:
      _1 = &f_2(D)->a;
      heh (_1);
      MEM <vector(2) char> [(char *)f_2(D) + 4B] = { 0, 0 };
      return;

    }

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

end of thread, other threads:[~2023-07-07  9:04 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-07 20:46 [Bug tree-optimization/96963] New: -Wstringop-overflow false positive on -O3 or -O2 -ftree-vectorize when assigning consecutive char struct members gcc_bugzilla at venus dot thegavinli.com
2020-09-07 23:15 ` [Bug tree-optimization/96963] " msebor at gcc dot gnu.org
2020-09-08  6:45 ` rguenth at gcc dot gnu.org
2020-09-08  8:18 ` gcc_bugzilla at venus dot thegavinli.com
2020-12-06 21:55 ` msebor at gcc dot gnu.org
2020-12-07 10:40 ` redi at gcc dot gnu.org
2020-12-07 10:43 ` [Bug tree-optimization/96963] [10/11 Regression] " redi at gcc dot gnu.org
2020-12-07 12:03 ` jakub at gcc dot gnu.org
2020-12-07 21:41 ` egallager at gcc dot gnu.org
2021-01-14  9:19 ` rguenth at gcc dot gnu.org
2021-01-21 21:21 ` msebor at gcc dot gnu.org
2021-01-21 23:49 ` msebor at gcc dot gnu.org
2021-03-04  0:05 ` cvs-commit at gcc dot gnu.org
2021-04-08 12:02 ` [Bug tree-optimization/96963] [10 " rguenth at gcc dot gnu.org
2021-07-21 16:24 ` pinskia at gcc dot gnu.org
2021-09-08 23:37 ` pinskia at gcc dot gnu.org
2022-03-17 19:45 ` msebor at gcc dot gnu.org
2022-06-28 10:41 ` jakub at gcc dot gnu.org
2023-02-04  4:42 ` pokechu022+gccbugzilla at gmail dot com
2023-07-07  9:04 ` rguenth 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).