Re: [PATCH] powerpc: mpc5200: Remove VLA usage
From: Segher Boessenkool <hidden>
Date: 2018-07-02 17:17:04
Also in:
lkml
From: Segher Boessenkool <hidden>
Date: 2018-07-02 17:17:04
Also in:
lkml
On Mon, Jul 02, 2018 at 11:33:32AM +1000, Michael Ellerman wrote:
What if we write it:
char saved_0x500[0x600 - 0x500];
Hopefully the compiler is smart enough not to generate a VLA for that :)It is a VLA if the array size is not an integer constant expression. This is defined by C; the compiler has nothing to do with it. 0x600-0x500 is an integer constant expression, so this is not a VLA. But if you meant if GCC will ever do a dynamic stack allocation for a fixed size local variable: yes indeed, I hope not! (Sometimes GCC can avoid this even with VLAs; but in this example we do not even have a VLA, so it's easier than that :-) ) Segher