From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id AFDF53858289; Sun, 8 Jan 2023 15:45:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AFDF53858289 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1673192705; bh=9BKoUQ+eMXd69uopTdC2Q/ihGud+DB+F1st3n+2A1RQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=fsHMH1tVbLsGZEdlXZcHwg0eG65YnY3O9sMIpbCMPegBM1QgcnyD9jQSxVQbHmXG2 JdNpdFS5QbQpS4/WpSgXZssxtSwo1ndtlvuzpptDuRFYsZZCGhVCsOh67ShnTewxdL NwYCqJ6nhKzJfZtG6a0+/MAh6tZ4/QkFphrST+Sk= From: "romain.geissler at amadeus dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/106238] Inline optimization causes dangling pointer on "include/c++/12.1.0/bits/stl_tree.h" Date: Sun, 08 Jan 2023 15:45:04 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 12.1.0 X-Bugzilla-Keywords: diagnostic, missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: romain.geissler at amadeus 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: cc Message-ID: In-Reply-To: References: 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D106238 Romain Geissler changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |romain.geissler at amadeus= dot com --- Comment #5 from Romain Geissler --- Hi, This seems to still happen with current trunk: #include std::map _Map; void f() { std::map localMap; _Map.swap(localMap); } compiled with -Wall -Werror -O2: In file included from /opt/compiler-explorer/gcc-trunk-20230108/include/c++/13.0.0/map:62, from :1: In member function 'void std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::swap(std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>&) [w= ith _Key =3D int; _Val =3D std::pair; _KeyOfValue =3D std::_Select1st >; _Compare =3D std::less; _= Alloc =3D std::allocator >]', inlined from 'void std::map<_Key, _Tp, _Compare, _Alloc>::swap(std::map<_Key, _Tp, _Compare, _Alloc>&) [with _Key =3D int; _= Tp =3D int; _Compare =3D std::less; _Alloc =3D std::allocator >]' at /opt/compiler-explorer/gcc-trunk-20230108/include/c++/13.0.0/bits/stl_map.h= :1172:18, inlined from 'void f()' at :8:14: /opt/compiler-explorer/gcc-trunk-20230108/include/c++/13.0.0/bits/stl_tree.= h:2091:36: error: storing the address of local variable 'localMap' in '*MEM[(struct _Rb_tree_node_base * &)&localMap + 16].std::_Rb_tree_node_base::_M_parent' [-Werror=3Ddangling-pointer=3D] 2091 | __t._M_root()->_M_parent =3D __t._M_end(); | ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~ : In function 'void f()': :7:24: note: 'localMap' declared here 7 | std::map localMap; | ^~~~~~~~ :7:24: note: 'localMap.std::map, std::allocator > >::_M_t.std::_Rb_tree, std::_Select1st >, std::less, std::allocator > >::_M_impl.std::_Rb_tree, std::_Select1st >, std::less, std::allocator > >::_Rb_tree_impl, true>::.std::_Rb_tree_header::_M_header.std::_Rb_tree_node_base::_= M_parent' declared here cc1plus: all warnings being treated as errors Compiler returned: 1 Cheers, Romain=