Skip to content

Commit cc5c554

Browse files
committed
Fix mismatched usize/u64 array element type
1 parent f5500c4 commit cc5c554

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

‎cpp2rust/converter/converter.cpp‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4998,9 +4998,9 @@ std::string Converter::ConvertPlaceholder(clang::Expr *expr, clang::Expr *arg,
49984998
}
49994999

50005000
if (ph_ctx.declared_in_rule_as_rust_ptr && arg->getType()->isArrayType()) {
5001-
return std::format(
5002-
"({} as {})", ConvertFreshPointer(arg),
5003-
Mapper::GetParamType(ctx_, GetCalleeOrExpr(expr), ph_ctx.arg_idx));
5001+
auto elem = ctx_.getAsArrayType(arg->getType())->getElementType();
5002+
return std::format("({} as {})", ConvertFreshPointer(arg),
5003+
ToStringBase(ctx_.getPointerType(elem)));
50045004
}
50055005

50065006
if (ph_ctx.needs_materialization()) {

‎tests/unit/out/refcount/size_t_ssize_t.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ fn main_0() -> i32 {
205205
let sizes: Value<Box<[usize]>> =
206206
Rc::new(RefCell::new(Box::new([1_usize, 2_usize, 3_usize, 4_usize])));
207207
let mut sizes_end: Ptr<usize> =
208-
((sizes.as_pointer() as Ptr<u64>).to_end()).reinterpret_cast::<usize>();
208+
((sizes.as_pointer() as Ptr<usize>).to_end()).reinterpret_cast::<usize>();
209209
assert!((((sizes_end).clone() - (sizes.as_pointer() as Ptr::<usize>)) as i64 == 4_i64));
210210
assert!((((sizes_end.offset(-((1) as isize))).read()) == 4_usize));
211211
return 0;

0 commit comments

Comments
 (0)