Linus Torvalds writes: (Summary) wrote:
I actually mis-read your example - in your case it obviously does pass the array itself down to the call, and yes, it obviously needs to be allocated.
allocated.
I had a test-case at one point where gcc avoided the stack allocation entirely for a regular array, but not for a VLA (of the same constant size) because the VLA logic is apparently different enough - even when the size of the array is a compile-time constant.
the size of the array is a compile-time constant.
We had that issue because we had a lot of trouble coming up with a "max()" macro that was still an I-C-E (and we had a number of array sizes that used "max()").
[...]
compiler optimization to change.I actually mis-read your example - in your case it obviously does pass the array itself down to the call, and yes, it obviously needs to be allocated.
allocated.
I had a test-case at one point where gcc avoided the stack allocation entirely for a regular array, but not for a VLA (of the same constant size) because the VLA logic is apparently different enough - even when the size of the array is a compile-time constant.
the size of the array is a compile-time constant.
We had that issue because we had a lot of trouble coming up with a "max()" macro that was still an I-C-E (and we had a number of array sizes that used "max()").