From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 7211A385B835; Sat, 18 Apr 2020 23:35:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7211A385B835 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1587252918; bh=oXzYVrCFuqW36VASWE1wPK/WfkL+jwlgg12YBj8JGVA=; h=From:To:Subject:Date:From; b=Efhu/p+gIG4+0x1uMOjVcuY6GdokUblwcgKKb9jhkvDY50T9IABYdL8/xSYihBogz KPIGusrHgRKqlwnWreDw23+R1W3BnoXzPFko0N7W6RQ+SKUTAA53wza573edv9Z/DP hD6J3ljxhTWTQb3Pakgs2n1WG6+CDqtLOdSSe5H4= From: "drahflow at gmx dot de" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/94655] New: Implicit assignment operator triggers stringop-overflow warning Date: Sat, 18 Apr 2020 23:35:18 +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.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: drahflow at gmx dot de 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: Sat, 18 Apr 2020 23:35:18 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94655 Bug ID: 94655 Summary: Implicit assignment operator triggers stringop-overflow warning Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: drahflow at gmx dot de Target Milestone: --- Running: g++-10 -O3 -W -Wall -Wextra -Werror --std=3Dc++2a -c problem.c++ on this code: #include #include #include struct A { std::string strA; // remove this line and it works char arr[16]; // remove this line and it works std::string strB; // remove this line and it works }; const A getA(); // remove "const" and it works void frob(const std::function &); struct B { int i; // remove this line and it works A data; B() { } void f(); }; void B::f() { frob([this]() { data =3D getA(); }); // data =3D getA(); // comment out the frob(...) and use this line, it wo= rks } results in: In member function =E2=80=98A& A::operator=3D(const A&)=E2=80=99, inlined from =E2=80=98B::f()::=E2=80=99 at problem.c++:26:17, inlined from =E2=80=98constexpr _Res std::__invoke_impl(std::__invoke_o= ther, _Fn&&, _Args&& ...) [with _Res =3D void; _Fn =3D B::f()::&; _Args =3D {}= ]=E2=80=99 at /usr/include/c++/10/bits/invoke.h:60:36, inlined from =E2=80=98constexpr std::enable_if_t, _Res> std::__invoke_r(_Callable&&, _Args&& ...) [with _Res =3D = void; _Callable =3D B::f()::&; _Args =3D {}]=E2=80=99 at /usr/include/c++/10/bits/invoke.h:110:28, inlined from =E2=80=98static _Res std::_Function_handler<_Res(_ArgTypes= ...), _Functor>::_M_invoke(const std::_Any_data&, _ArgTypes&& ...) [with _Res =3D= void; _Functor =3D B::f()::; _ArgTypes =3D {}]=E2=80=99 at /usr/include/c++/10/bits/std_function.h:291:30: problem.c++:5:8: error: writing 16 bytes into a region of size 0 [-Werror=3Dstringop-overflow=3D] 5 | struct A { | ^ problem.c++: In static member function =E2=80=98static _Res std::_Function_handler<_Res(_ArgTypes ...), _Functor>::_M_invoke(const std::_Any_data&, _ArgTypes&& ...) [with _Res =3D void; _Functor =3D B::f()::; _ArgTypes =3D {}]=E2=80=99: problem.c++:6:15: note: at offset 0 to object =E2=80=98A::strA=E2=80=99 wit= h size 32 declared here 6 | std::string strA; // remove this line and it works | ^~~~ Using instead -O2, it works. Using instead g++9, it works. % g++-10 --version g++-10 (Debian 10-20200222-1) 10.0.1 20200222 (experimental) [master revisi= on 01af7e0a0c2:487fe13f218:e99b18cf7101f205bfdd9f0f29ed51caaec52779]=