================
@@ -5495,14 +5495,12 @@ static void TryOrBuildParenListInitialization(
         return;
     }
     //   ...and value-initialized for each k < i <= n;
-    if (ArrayLength > Args.size()) {
----------------
alanzhao1 wrote:

> What is this change supposed to do?

`CodeGenFunction::EmitNewArrayInitializer(...)` needs an array filler for 
dynamic-sized arrays - e.g.

```cpp
void foo(int n) {
  new int[n](1, 2);
}
```

> The existing code is intentionally trying to avoid creating an array filler 
> if it won't be used (so, for example, the code will compile if the default 
> constructor is deleted).

Thanks for pointing this out! There was no test for this case with a deleted 
constructor, so I'll have to create a separate PR to add one later.

In the meantime, I resolved this by adding `Entity.isVariableLengthArrayNew()` 
to the conditional here. This is also what we do in `InitListChecker` to detect 
this condition.


https://github.com/llvm/llvm-project/pull/76976
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to