Skip to content

Commit 43e83b9

Browse files
authored
[clang][bytecode] Fix allocating primitive arrays of unknown bound (#127788)
1 parent 2c8b124 commit 43e83b9

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3397,7 +3397,8 @@ bool Compiler<Emitter>::VisitCXXNewExpr(const CXXNewExpr *E) {
33973397
CtorFunc = getFunction(CE->getConstructor());
33983398
if (!CtorFunc)
33993399
return false;
3400-
}
3400+
} else if (!DynamicInit)
3401+
DynamicInit = Init;
34013402

34023403
LabelTy EndLabel = this->getLabel();
34033404
LabelTy StartLabel = this->getLabel();

clang/test/AST/ByteCode/new-delete.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -907,6 +907,12 @@ namespace IncompleteArray {
907907
return c;
908908
}
909909
static_assert(test4() == 12);
910+
911+
912+
constexpr char *f(int n) {
913+
return new char[n]();
914+
}
915+
static_assert((delete[] f(2), true));
910916
}
911917

912918
namespace NonConstexprArrayCtor {

0 commit comments

Comments
 (0)