public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "ercli at ucdavis dot edu" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/105100] New: Strange warning when modifying structures "writing 1 byte into a region of size 0" when compile with -O3
Date: Tue, 29 Mar 2022 18:31:53 +0000	[thread overview]
Message-ID: <bug-105100-4@http.gcc.gnu.org/bugzilla/> (raw)

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

             reply	other threads:[~2022-03-29 18:31 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-29 18:31 ercli at ucdavis dot edu [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-105100-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).