Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cpp2rust/converter/converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3709,6 +3709,7 @@ std::string Converter::ConvertPlaceholder(clang::Expr *expr, clang::Expr *arg,
ph_ctx.is_index_base
? std::optional(ph_ctx.access == TranslationRule::Access::kWrite)
: std::nullopt);
PushExprKind push(*this, ExprKind::RValue);
ConvertDeref(arg);
return std::move(buf).str();
}
Expand Down
5 changes: 5 additions & 0 deletions tests/unit/out/refcount/vector_addr_of_back.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,10 @@ fn main_0() -> i32 {
((*outer.borrow())[(*outer.borrow()).len() - 1].as_pointer()),
));
assert!(((*(*sink.borrow()).upgrade().deref()).len() as u64 == 0_u64));
let p: Value<Ptr<Vec<Value<Vec<i32>>>>> = Rc::new(RefCell::new((outer.as_pointer())));
(*sink.borrow_mut()) = ((*(*p.borrow()).upgrade().deref())
[(*(*p.borrow()).upgrade().deref()).len() - 1]
.as_pointer());
assert!(((*(*sink.borrow()).upgrade().deref()).len() as u64 == 0_u64));
return 0;
}
3 changes: 3 additions & 0 deletions tests/unit/out/unsafe/vector_addr_of_back.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,8 @@ unsafe fn main_0() -> i32 {
outer.push(inner.clone());
let mut sink: *mut Vec<i32> = ((outer).last_mut().unwrap());
assert!((((*sink.cast_const()).len() as u64) == (0_u64)));
let mut p: *mut Vec<Vec<i32>> = (&mut outer as *mut Vec<Vec<i32>>);
sink = ((*p).last_mut().unwrap());
assert!((((*sink.cast_const()).len() as u64) == (0_u64)));
return 0;
}
5 changes: 5 additions & 0 deletions tests/unit/vector_addr_of_back.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,10 @@ int main() {
outer.push_back(inner);
auto *sink = &outer.back();
assert(sink->size() == 0);

auto *p = &outer;
sink = &p->back();
assert(sink->size() == 0);

return 0;
}
Loading