From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id AA794385702F; Sun, 6 Dec 2020 01:21:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AA794385702F From: "darklythinking at yahoo dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/98158] New: Gcc generates warning about its own generated move assignment operator Date: Sun, 06 Dec 2020 01:21:06 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 10.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: darklythinking at yahoo dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Dec 2020 01:21:08 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D98158 Bug ID: 98158 Summary: Gcc generates warning about its own generated move assignment operator Product: gcc Version: 10.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: darklythinking at yahoo dot com Target Milestone: --- Version: $ gcc --version gcc (Gentoo 10.2.0-r3 p4) 10.2.0 System: The bug doesn't happen if no arch is specified but with -march=3Dskylake or -march=3Dznver2 the warning appears(and probably others but those are the 2= I tested) Code: #include #include struct test { std::string a; std::uint8_t b[16]; std::uint8_t c[16]; }; test function(test blah) { blah =3D {}; return blah; } int main(int argc, char *argv[]) { return 0; } Output: $ g++ -O3 -march=3Dskylake test.cpp In member function =E2=80=98test& test::operator=3D(test&&)=E2=80=99, inlined from =E2=80=98test function(test)=E2=80=99 at test.cpp:13:10: test.cpp:4:8: warning: writing 32 bytes into a region of size 16 [-Wstringop-overflow=3D] 4 | struct test | ^~~~ test.cpp: In function =E2=80=98test function(test)=E2=80=99: test.cpp:7:15: note: at offset 0 to object =E2=80=98test::b=E2=80=99 with s= ize 16 declared here 7 | std::uint8_t b[16]; | ^ Note that the warning actually happens in a move assignment operator genera= ted by gcc itself. The warning also appears if std::vector is used instead of the std::string = but I wasn't able to replace it with a struct or static array of any size and reproduce the bug that way.=