[Bug c++/101558] New: Abnormal behavior with -O3 : warning: writing 8 bytes into a region of size 0 [-Wstringop-overflow=]
franco at francocorbelli dot com
gcc-bugzilla@gcc.gnu.org
Wed Jul 21 15:13:41 GMT 2021
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101558
Bug ID: 101558
Summary: Abnormal behavior with -O3 : warning: writing 8 bytes
into a region of size 0 [-Wstringop-overflow=]
Product: gcc
Version: og10 (devel/omp/gcc-10)
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: franco at francocorbelli dot com
Target Milestone: ---
Created attachment 51188
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51188&action=edit
Snippet of "strange" behavior
On GCC 10.3.0 on Ubuntu 21
(...)COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/10/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa:hsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 10.3.0-1ubuntu1'
(...)Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 10.3.0 (Ubuntu 10.3.0-1ubuntu1)
I get problems porting software from previous versions (8.x).
In particular, there is a warning message of this kind
"
In member function ‘unzDT& unzDT::operator=(const unzDT&)’,
inlined from ‘int main()’ at unz.cpp:27:9:
unz.cpp:11:8: warning: writing 8 bytes into a region of size 0
[-Wstringop-overflow=]
11 | struct unzDT
| ^~~~~
unz.cpp: In function ‘int main()’:
unz.cpp:13:12: note: at offset 0 to object ‘unzDT::date’ with size 8 declared
here
13 | uint64_t date;
|
"
It is reproducible with the attached snippet, by compiling with -O3
g++ -O3 unz.cpp -o unz
If you want to see more "oddities" try to change the size of
sha1decompressedhex from 8 to 7
More information about the Gcc-bugs
mailing list