https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107633
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> --- (In reply to Rainer Orth from comment #0) > /vol/gcc/src/hg/master/rust/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<std::unique_ptr<Rust::HIR::TypePathSegment> >&, std::size_t, > Rust::TyTy::BaseType*, const Rust::Analysis::NodeMapping&, Location)': > /vol/gcc/src/hg/master/rust/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 (); This should probably be: auto first = candidates.begin (); auto &candidate = *first; so that the iterator persists as long as its value is needed.