Skip to content

Commit 8cdf97c

Browse files
committed
Avoid from_fn in const initializer
1 parent 0097f64 commit 8cdf97c

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

cpp2rust/converter/converter.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3151,6 +3151,10 @@ bool Converter::VisitImplicitValueInitExpr(clang::ImplicitValueInitExpr *expr) {
31513151
if (auto arr_ty = clang::dyn_cast<clang::ArrayType>(
31523152
expr->getType()->getCanonicalTypeInternal().getTypePtr())) {
31533153
if (auto const_arr_ty = clang::dyn_cast<clang::ConstantArrayType>(arr_ty)) {
3154+
if (const_arr_ty->getElementType()->isCharType()) {
3155+
StrCat(std::format("[0; {}]", const_arr_ty->getSize().getZExtValue()));
3156+
return false;
3157+
}
31543158
StrCat(
31553159
std::format("std::array::from_fn::<_, {}, _>(|_| Default::default())",
31563160
const_arr_ty->getSize().getZExtValue()));

0 commit comments

Comments
 (0)