public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "darklythinking at yahoo dot com" <gcc-bugzilla@gcc.gnu.org> 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 [thread overview] Message-ID: <bug-98158-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98158 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=skylake or -march=znver2 the warning appears(and probably others but those are the 2 I tested) Code: #include <string> #include <cstdint> struct test { std::string a; std::uint8_t b[16]; std::uint8_t c[16]; }; test function(test blah) { blah = {}; return blah; } int main(int argc, char *argv[]) { return 0; } Output: $ g++ -O3 -march=skylake test.cpp In member function ‘test& test::operator=(test&&)’, inlined from ‘test function(test)’ at test.cpp:13:10: test.cpp:4:8: warning: writing 32 bytes into a region of size 16 [-Wstringop-overflow=] 4 | struct test | ^~~~ test.cpp: In function ‘test function(test)’: test.cpp:7:15: note: at offset 0 to object ‘test::b’ with size 16 declared here 7 | std::uint8_t b[16]; | ^ Note that the warning actually happens in a move assignment operator generated 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.
next reply other threads:[~2020-12-06 1:21 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-12-06 1:21 darklythinking at yahoo dot com [this message] 2020-12-06 9:34 ` [Bug c++/98158] [10/11 Regression] Gcc generates warning about its own generated move assignment operator since r10-3657-gdaa94de24b9afdf2 marxin at gcc dot gnu.org 2020-12-06 21:55 ` msebor 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-98158-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: linkBe 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).