It is unsafe to deref raw pointers during autoderef this adds a check to
stop autoderef early when we are about to try and deref pointers.
Fixes #2015
gcc/rust/ChangeLog:
* typecheck/rust-autoderef.cc (AutoderefCycle::cycle): add check for pointers
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
return false;
// try unsize
-
Adjustment unsize = Adjuster::try_unsize_type (r);
if (!unsize.is_error ())
{
adjustments.pop_back ();
}
+ bool is_ptr = receiver->get_kind () == TyTy::TypeKind::POINTER;
+ if (is_ptr)
+ {
+ // deref of raw pointers is unsafe
+ return false;
+ }
+
Adjustment deref
= Adjuster::try_deref_type (r, Analysis::RustLangItem::ItemType::DEREF);
if (!deref.is_error ())