@@ -500,12 +500,19 @@ ConverterRefCount::MaterializeTemp(const std::string &binding_name,
500500 clang::QualType param_type,
501501 clang::Expr *expr) {
502502 auto pointee = param_type.getNonReferenceType ();
503- auto value = ConvertFreshRValue (expr, pointee);
504- auto type_str = ToStringBase (pointee);
505503 const auto *decl = in_const_initializer_ ? keyword::kStatic : keyword::kLet ;
506-
507- auto binding = std::format (" {} {} : Value<{}> = Rc::new(RefCell::new({}));" ,
508- decl, binding_name, type_str, value);
504+ std::string binding;
505+ if (pointee->isConstantArrayType ()) {
506+ PushConversionKind push (*this , ConversionKind::FullRefCount);
507+ binding =
508+ std::format (" {} {} : {} = {};" , decl, binding_name, ToString (pointee),
509+ BoxValue (ConvertVarInitValue (pointee, expr)));
510+ } else {
511+ auto value = ConvertFreshRValue (expr, pointee);
512+ auto type_str = ToStringBase (pointee);
513+ binding = std::format (" {} {} : Value<{}> = Rc::new(RefCell::new({}));" ,
514+ decl, binding_name, type_str, value);
515+ }
509516 auto ref =
510517 in_const_initializer_ ? " .with(Value::as_pointer)" : " .as_pointer()" ;
511518 return {binding, binding_name + ref};
@@ -3041,6 +3048,9 @@ void ConverterRefCount::ConvertPointerSubscript(
30413048 ConvertPointerElem (base, idx);
30423049 } else {
30433050 ConvertPointerOffset (base, idx);
3051+ if (expr->getType ()->isArrayType ()) {
3052+ StrCat (GetPointerDerefSuffix (expr->getType ()), " .as_pointer()" );
3053+ }
30443054 }
30453055 if (deref) {
30463056 StrCat (GetPointerDerefSuffix (expr->getType ()));
@@ -3122,6 +3132,11 @@ void ConverterRefCount::ConvertDeref(clang::Expr *expr) {
31223132 str = std::move (buf).str ();
31233133 }
31243134
3135+ if (isAddrOf () && pointee_type->isArrayType ()) {
3136+ str = std::format (" ({}){}.as_pointer()" , std::move (str),
3137+ GetPointerDerefSuffix (pointee_type));
3138+ }
3139+
31253140 if (isObject () && WantsElementPtr () &&
31263141 (IsBoxedType (ctx_, pointee_type) || pointee_type->isArrayType ())) {
31273142 StrCat (std::format (" Ptr::<{}>::decay(&({}))" , ToString (pointee_type),
0 commit comments