public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/105100] New: Strange warning when modifying structures "writing 1 byte into a region of size 0" when compile with -O3
@ 2022-03-29 18:31 ercli at ucdavis dot edu
  2022-03-30  6:59 ` [Bug c/105100] [10/11/12 RegressionStrange " rguenth at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: ercli at ucdavis dot edu @ 2022-03-29 18:31 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 105100
           Summary: Strange warning when modifying structures "writing 1
                    byte into a region of size 0" when compile with -O3
           Product: gcc
           Version: 11.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ercli at ucdavis dot edu
  Target Milestone: ---

Created attachment 52715
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52715&action=edit
Preprocessor output that triggers the bug

I am compiling a function that reads a byte array and converts it to
structures. I find strange compiler warnings when using -O3 optimization.

See attachment from line 10 for a minimize test case. My source code is named
b.c, which does not contain any includes.

The exact version of GCC:
gcc (GCC) 11.2.1 20220127 (Red Hat 11.2.1-9)
Also see compiler output below

The system type:
Fedora 35 Workstation, kernel 5.16.16-200.fc35.x86_64

The options given when GCC was configured/built:
See compiler output below

The complete command line that triggers the bug:
gcc -v -save-temps -O3 -Wall -Werror -c -o b.o b.c

The compiler output (error messages, warnings, etc.):
Using built-in specs.
COLLECT_GCC=gcc
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap
--enable-languages=c,c++,fortran,objc,obj-c++,ada,go,d,lto --prefix=/usr
--mandir=/usr/share/man --infodir=/usr/share/info
--with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared
--enable-threads=posix --enable-checking=release --enable-multilib
--with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions
--enable-gnu-unique-object --enable-linker-build-id
--with-gcc-major-version-only --with-linker-hash-style=gnu --enable-plugin
--enable-initfini-array
--with-isl=/builddir/build/BUILD/gcc-11.2.1-20220127/obj-x86_64-redhat-linux/isl-install
--enable-offload-targets=nvptx-none --without-cuda-driver
--enable-gnu-indirect-function --enable-cet --with-tune=generic
--with-arch_32=i686 --build=x86_64-redhat-linux
--with-build-config=bootstrap-lto --enable-link-serialization=1
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.2.1 20220127 (Red Hat 11.2.1-9) (GCC) 
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-O3' '-Wall' '-Werror' '-c' '-o' 'b.o'
'-mtune=generic' '-march=x86-64'
 /usr/libexec/gcc/x86_64-redhat-linux/11/cc1 -E -quiet -v b.c -mtune=generic
-march=x86-64 -Wall -Werror -O3 -fpch-preprocess -o b.i
ignoring nonexistent directory
"/usr/lib/gcc/x86_64-redhat-linux/11/include-fixed"
ignoring nonexistent directory
"/usr/lib/gcc/x86_64-redhat-linux/11/../../../../x86_64-redhat-linux/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/x86_64-redhat-linux/11/include
 /usr/local/include
 /usr/include
End of search list.
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-O3' '-Wall' '-Werror' '-c' '-o' 'b.o'
'-mtune=generic' '-march=x86-64'
 /usr/libexec/gcc/x86_64-redhat-linux/11/cc1 -fpreprocessed b.i -quiet
-dumpbase b.c -dumpbase-ext .c -mtune=generic -march=x86-64 -O3 -Wall -Werror
-version -o b.s
GNU C17 (GCC) version 11.2.1 20220127 (Red Hat 11.2.1-9) (x86_64-redhat-linux)
        compiled by GNU C version 11.2.1 20220127 (Red Hat 11.2.1-9), GMP
version 6.2.0, MPFR version 4.1.0-p13, MPC version 1.2.1, isl version
isl-0.18-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU C17 (GCC) version 11.2.1 20220127 (Red Hat 11.2.1-9) (x86_64-redhat-linux)
        compiled by GNU C version 11.2.1 20220127 (Red Hat 11.2.1-9), GMP
version 6.2.0, MPFR version 4.1.0-p13, MPC version 1.2.1, isl version
isl-0.18-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 8878ef997f8884938fae95d09b5e3a52
b.c: In function 'func':
b.c:28:31: error: writing 1 byte into a region of size 0
[-Werror=stringop-overflow=]
   28 |                         pb[i] = src[0];
      |                         ~~~~~~^~~~~~~~
b.c:9:18: note: at offset 2 into destination object 'a' of size 2
    9 |         uint16_t a;
      |                  ^
b.c:28:31: error: writing 1 byte into a region of size 0
[-Werror=stringop-overflow=]
   28 |                         pb[i] = src[0];
      |                         ~~~~~~^~~~~~~~
b.c:9:18: note: at offset 3 into destination object 'a' of size 2
    9 |         uint16_t a;
      |                  ^
cc1: all warnings being treated as errors

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

* [Bug c/105100] [10/11/12 RegressionStrange warning when modifying structures "writing 1 byte into a region of size 0" when compile with -O3
  2022-03-29 18:31 [Bug c/105100] New: Strange warning when modifying structures "writing 1 byte into a region of size 0" when compile with -O3 ercli at ucdavis dot edu
@ 2022-03-30  6:59 ` rguenth at gcc dot gnu.org
  2022-03-30  7:06 ` [Bug c/105100] [10/11/12 Regression] Strange " rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-03-30  6:59 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2022-03-30
            Summary|Strange warning when        |[10/11/12 RegressionStrange
                   |modifying structures        |warning when modifying
                   |"writing 1 byte into a      |structures "writing 1 byte
                   |region of size 0" when      |into a region of size 0"
                   |compile with -O3            |when compile with -O3
           Keywords|                            |diagnostic

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed.

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

* [Bug c/105100] [10/11/12 Regression] Strange warning when modifying structures "writing 1 byte into a region of size 0" when compile with -O3
  2022-03-29 18:31 [Bug c/105100] New: Strange warning when modifying structures "writing 1 byte into a region of size 0" when compile with -O3 ercli at ucdavis dot edu
  2022-03-30  6:59 ` [Bug c/105100] [10/11/12 RegressionStrange " rguenth at gcc dot gnu.org
@ 2022-03-30  7:06 ` rguenth at gcc dot gnu.org
  2022-06-28 10:48 ` [Bug c/105100] [10/11/12/13 " jakub at gcc dot gnu.org
  2023-07-07 10:42 ` [Bug tree-optimization/105100] [11/12/13/14 " rguenth at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-03-30  7:06 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[10/11/12 RegressionStrange |[10/11/12 Regression]
                   |warning when modifying      |Strange warning when
                   |structures "writing 1 byte  |modifying structures
                   |into a region of size 0"    |"writing 1 byte into a
                   |when compile with -O3       |region of size 0" when
                   |                            |compile with -O3
           Priority|P3                          |P2
   Target Milestone|---                         |10.4
      Known to work|                            |9.4.0

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
There might be a duplicate.  It's the usual address CSE issue. 
-fno-code-hoisting avoids it in this case.

   <bb 3> [local count: 184361477]:
-  [t.c:23:12] pb_17 = [t.c:23:29] &[t.c:23:34] [t.c:23:34] MEM[(struct b_t
*)dst_13(D)].b;
+  [t.c:23:12] pretmp_29 = &MEM <struct c_t> [(void *)dst_13(D)].c.a;

and PRE does

   <bb 2> [local count: 542239628]:
   [t.c:21:7] _1 = [t.c:21:7] MEM[(uint32_t *)dst_13(D)];
+  [t.c:23:12] pretmp_29 = &MEM <struct c_t> [(void *)dst_13(D)].c.a;
   [t.c:21:5] if (_1 == 1)
...
-  <bb 3> [local count: 184361475]:
-  [t.c:23:12] pb_17 = [t.c:23:29] &[t.c:23:34] [t.c:23:34] MEM[(struct b_t
*)dst_13(D)].b;
...
-  <bb 5> [local count: 357878152]:
-  [t.c:29:12] pc_14 = [t.c:29:29] &[t.c:29:37] [t.c:29:34] [t.c:29:34]
MEM[(struct c_t *)dst_13(D)].c.a;
+  <bb 4> [local count: 357878152]:

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

* [Bug c/105100] [10/11/12/13 Regression] Strange warning when modifying structures "writing 1 byte into a region of size 0" when compile with -O3
  2022-03-29 18:31 [Bug c/105100] New: Strange warning when modifying structures "writing 1 byte into a region of size 0" when compile with -O3 ercli at ucdavis dot edu
  2022-03-30  6:59 ` [Bug c/105100] [10/11/12 RegressionStrange " rguenth at gcc dot gnu.org
  2022-03-30  7:06 ` [Bug c/105100] [10/11/12 Regression] Strange " rguenth at gcc dot gnu.org
@ 2022-06-28 10:48 ` jakub at gcc dot gnu.org
  2023-07-07 10:42 ` [Bug tree-optimization/105100] [11/12/13/14 " rguenth at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-06-28 10:48 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|10.4                        |10.5

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 10.4 is being released, retargeting bugs to GCC 10.5.

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

* [Bug tree-optimization/105100] [11/12/13/14 Regression] Strange warning when modifying structures "writing 1 byte into a region of size 0" when compile with -O3
  2022-03-29 18:31 [Bug c/105100] New: Strange warning when modifying structures "writing 1 byte into a region of size 0" when compile with -O3 ercli at ucdavis dot edu
                   ` (2 preceding siblings ...)
  2022-06-28 10:48 ` [Bug c/105100] [10/11/12/13 " jakub at gcc dot gnu.org
@ 2023-07-07 10:42 ` rguenth at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-07-07 10:42 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|10.5                        |11.5

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 10 branch is being closed.

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

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

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-29 18:31 [Bug c/105100] New: Strange warning when modifying structures "writing 1 byte into a region of size 0" when compile with -O3 ercli at ucdavis dot edu
2022-03-30  6:59 ` [Bug c/105100] [10/11/12 RegressionStrange " rguenth at gcc dot gnu.org
2022-03-30  7:06 ` [Bug c/105100] [10/11/12 Regression] Strange " rguenth at gcc dot gnu.org
2022-06-28 10:48 ` [Bug c/105100] [10/11/12/13 " jakub at gcc dot gnu.org
2023-07-07 10:42 ` [Bug tree-optimization/105100] [11/12/13/14 " 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).