mc-imperial / dredd

Framework for evaluating C/C++ compiler testing tools
Apache License 2.0
11 stars 3 forks source link

Avoid mutation of array-size expression in C++ `new` expression #272

Closed JonathanFoo0523 closed 1 month ago

JonathanFoo0523 commented 1 month ago

In C++, one can initialize a list of items of type a with the expression new a[2]{3, 4}. Using a non-constant array size requires the type a to have a zero-argument constructor. Since applying mutation to the array size (i.e., 2 in the given example) would change the constant array size to non-constant, and we aren't sure whether type a contains a zero-argument constructor, we avoid mutating the array size altogether.

Fixes #265

afd commented 1 month ago

Your PR description, but wrapped to 72 chars, will make a good commit message. I'd change "Fix" to "Fixes" (can't remember if "Fix" will auto-close, but I prefer "Fixes" anyway).