From: bors[bot] <26634292+bors[bot]@users.noreply.github.com> Date: Wed, 14 Dec 2022 14:46:30 +0000 (+0000) Subject: Merge #1703 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3b89428c0d5710c8093055b3d92c543888759f93;p=thirdparty%2Fgcc.git 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 --- 3b89428c0d5710c8093055b3d92c543888759f93