From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1643) id 723693886A2C; Wed, 14 Dec 2022 15:40:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 723693886A2C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1671032428; bh=JbZ3XeKKooyFdN0CdlVAcUA+CXX1QD2MMq/5XpjyktE=; h=From:To:Subject:Date:From; b=Il8dYGQWzGZu5My1JnPFTPxwgnBS+0/OMXSB0OWQmHsnzbWF2Vz/2xHh+JIaJX2f/ EI0EmeN+EICb0nzaCQYmDD86sonDnmGAKXB2vw2zk1wU1hsytDSKzrPJCUjN808SYQ xufZq+k1/Lyfyrg/PASpxwDWidqbVx+uhIS1bxog= MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="utf-8" From: Thomas Schwinge To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/rust/master] Merge #1703 X-Act-Checkin: gcc X-Git-Author: bors[bot] <26634292+bors[bot]@users.noreply.github.com> X-Git-Refname: refs/heads/devel/rust/master X-Git-Oldrev: 3d6dbb6fc5d1d14bf36a879b6f4a00ae91090a63 X-Git-Newrev: 3b89428c0d5710c8093055b3d92c543888759f93 Message-Id: <20221214154028.723693886A2C@sourceware.org> Date: Wed, 14 Dec 2022 15:40:28 +0000 (GMT) List-Id: https://gcc.gnu.org/g:3b89428c0d5710c8093055b3d92c543888759f93 commit 3b89428c0d5710c8093055b3d92c543888759f93 Merge: 3d6dbb6fc5d 5c2e6c93d91 Author: bors[bot] <26634292+bors[bot]@users.noreply.github.com> Date: Wed Dec 14 14:46:30 2022 +0000 Merge #1703 1703: Backport "c++: Quash -Wdangling-reference for member operator* [PR107488]" r=tschwinge a=tschwinge As had also been reported in "Bootstrap failure due to -Werror=unused-parameter and -Werror=dangling-reference", GCC `--enable-bootstrap` build is currently broken: [...]/gcc/rust/backend/rust-compile-expr.cc: In member function ‘tree_node* Rust::Compile::CompileExpr::resolve_method_address(Rust::TyTy::FnType*, Rust::HirId, Rust::TyTy::BaseType*, Rust::HIR::PathIdentSegment&, Rust::Analysis::NodeMapping, Location)’: [...]/gcc/rust/backend/rust-compile-expr.cc:2019:13: error: possibly dangling reference to a temporary [-Werror=dangling-reference] 2019 | auto &candidate = *candidates.begin (); | ^~~~~~~~~ [...]/gcc/rust/backend/rust-compile-expr.cc:2019:44: note: the temporary was destroyed at the end of the full expression ‘candidates.std::set::begin().std::_Rb_tree_const_iterator::operator*()’ 2019 | auto &candidate = *candidates.begin (); | ^ [...]/gcc/rust/backend/rust-compile-expr.cc: In member function ‘tree_node* Rust::Compile::CompileExpr::generate_closure_fntype(Rust::HIR::ClosureExpr&, const Rust::TyTy::ClosureType&, tree, Rust::TyTy::FnType**)’: [...]/gcc/rust/backend/rust-compile-expr.cc:3034:35: error: possibly dangling reference to a temporary [-Werror=dangling-reference] 3034 | const TyTy::TypeBoundPredicate &predicate | ^~~~~~~~~ [...]/gcc/rust/backend/rust-compile-expr.cc:3035:52: note: the temporary was destroyed at the end of the full expression ‘(&(& closure_tyty)->Rust::TyTy::ClosureType::.Rust::TyTy::BaseType::.Rust::TyTy::TypeBoundsMappings::get_specified_bounds())->std::vector::begin().__gnu_cxx::__normal_iterator >::operator*()’ 3035 | = *closure_tyty.get_specified_bounds ().begin (); | ^ [...]/gcc/rust/typecheck/rust-hir-type-check-path.cc: In member function ‘void Rust::Resolver::TypeCheckExpr::resolve_segments(Rust::NodeId, std::vector&, size_t, Rust::TyTy::BaseType*, const Rust::Analysis::NodeMapping&, Location)’: [...]/gcc/rust/typecheck/rust-hir-type-check-path.cc:340:13: error: possibly dangling reference to a temporary [-Werror=dangling-reference] 340 | auto &candidate = *candidates.begin (); | ^~~~~~~~~ [...]/gcc/rust/typecheck/rust-hir-type-check-path.cc:340:44: note: the temporary was destroyed at the end of the full expression ‘candidates.std::set::begin().std::_Rb_tree_const_iterator::operator*()’ 340 | auto &candidate = *candidates.begin (); | ^ [...]/gcc/rust/typecheck/rust-hir-type-check-type.cc: In member function ‘Rust::TyTy::BaseType* Rust::Resolver::TypeCheckType::resolve_segments(Rust::NodeId, Rust::HirId, std::vector >&, size_t, Rust::TyTy::BaseType*, const Rust::Analysis::NodeMapping&, Location)’: [...]/gcc/rust/typecheck/rust-hir-type-check-type.cc:465:13: error: possibly dangling reference to a temporary [-Werror=dangling-reference] 465 | auto &candidate = *candidates.begin (); | ^~~~~~~~~ [...]/gcc/rust/typecheck/rust-hir-type-check-type.cc:465:44: note: the temporary was destroyed at the end of the full expression ‘candidates.std::set::begin().std::_Rb_tree_const_iterator::operator*()’ 465 | auto &candidate = *candidates.begin (); | ^ I understand this code has been changed in the GCC/Rust upstream submission; but in order to make progress with #1700, I'd like to first individually backport "c++: Quash -Wdangling-reference for member operator* [PR107488]", to resolve this issue here. Co-authored-by: Marek Polacek Diff: gcc/cp/call.cc | 12 +++++++++++- gcc/testsuite/g++.dg/warn/Wdangling-reference5.C | 22 ++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-)