On Thu, Apr 5, 2018 at 3:51 PM, James Y Knight <jykni...@google.com> wrote: > > Unfortunately, that behavior is required by the standard, it's not up to > 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. 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. 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()"). So all the array sizes were compile-time constants, they just weren't traditional C arrays. But now I can't recreate the thing. Maybe I had screwed up in my test-case somehow. Linus