https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102248
Bug ID: 102248 Summary: -Wstringop-overflow false positive Product: gcc Version: 10.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: eugene.chereshnev at intel dot com Target Milestone: --- Created attachment 51428 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51428&action=edit Preprocessed file Observing false positive with 10.x versions, 9.x and 11.x versions are good. Reproduced only with -O3. $ g++ --version g++ (GCC) 10.3.0 Copyright (C) 2020 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. $ cat 1.cpp #include <cstdint> struct Foo { int8_t a, b; Foo(): a(0), b(1) {} }; struct Bar { Bar(); Foo x0; Foo x1; Foo x2; Foo x3; }; void foo(Foo&); Bar::Bar() { foo(x0); } $ g++ -c -O3 1.cpp In constructor ‘Foo::Foo()’, inlined from ‘Bar::Bar()’ at 1.cpp:21:10: 1.cpp:6:21: warning: writing 8 bytes into a region of size 2 [-Wstringop-overflow=] 6 | Foo(): a(0), b(1) {} | ^ 1.cpp: In constructor ‘Bar::Bar()’: 1.cpp:12:9: note: at offset 0 to object ‘Bar::x0’ with size 2 declared here 12 | Foo x0; | ^~ Godbolt link: https://godbolt.org/z/W7e4PqK7n