From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 513D43858009; Tue, 1 Nov 2022 08:03:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 513D43858009 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1667289782; bh=9PEk4kUu+GFJcpL8Aed40qfgvrIHFPo9/AtfCN/mUeo=; h=From:To:Subject:Date:From; b=qGQTAn3BTeuFG/pteL8ikFg91JhK/Dna+mrMLvU8C9qLk1YFYigJcPexpsYLjawkP kkT242KdZ2ImQ3yl/wA6Lz28xIHCXzI4O6gdwRxT9U6HyzXHcOgrYpELow5FZrRVqo B/FD89V6XtUA6ozQ03GprNnjp5iroWBxFZE/rr5k= From: "slyfox at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/107488] New: [13 Regression] -Werror=dangling-reference false positives in cppunit Date: Tue, 01 Nov 2022 08:02:58 +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: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: slyfox at gcc dot gnu.org 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107488 Bug ID: 107488 Summary: [13 Regression] -Werror=3Ddangling-reference false positives in cppunit Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: slyfox at gcc dot gnu.org Target Milestone: --- cppunit-1.15.1 and a few other projects fail to compile due to -Werror on -Werror=3Ddangling-reference. I think those are false positives. Extracted example from cppunit: // $ cat a.cpp.cpp #include int attributesAsString(std::vector & v) { int attributes; std::vector::const_iterator itAttribute =3D v.begin(); while ( itAttribute !=3D v.end() ) { const int &attribute =3D *itAttribute++; attributes +=3D attribute; } return attributes; } $ g++-13.0.0 -Werror=3Ddangling-reference -c a.cpp.cpp -o a.o a.cpp.cpp: In function 'int attributesAsString(std::vector&)': a.cpp.cpp:12:16: error: possibly dangling reference to a temporary [-Werror=3Ddangling-reference] 12 | const int &attribute =3D *itAttribute++; | ^~~~~~~~~ a.cpp.cpp:12:40: note: the temporary was destroyed at the end of the full expression 'itAttribute.__gnu_cxx::__normal_iterator >::operator++(0).__gnu_cxx::__normal_iterator >::operator*()' 12 | const int &attribute =3D *itAttribute++; | ^~ $ g++-13.0.0 -v Using built-in specs. COLLECT_GCC=3D/<>/gcc-13.0.0/bin/g++ COLLECT_LTO_WRAPPER=3D/<>/gcc-13.0.0/libexec/gcc/x86_64-unknown-linux-= gnu/13.0.0/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: Thread model: posix Supported LTO compression algorithms: zlib gcc version 13.0.0 20221030 (experimental) (GCC)=