From: Segher Boessenkool <segher@kernel.crashing.org>
To: Michael Ellerman <mpe@ellerman.id.au>
Cc: Kees Cook <keescook@chromium.org>, Arnd Bergmann <arnd@arndb.de>,
Paul Mackerras <paulus@samba.org>,
Anatolij Gustschin <agust@denx.de>,
linuxppc-dev <linuxppc-dev@lists.ozlabs.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] powerpc: mpc5200: Remove VLA usage
Date: Mon, 2 Jul 2018 12:16:31 -0500 [thread overview]
Message-ID: <20180702171631.GA16221@gate.crashing.org> (raw)
In-Reply-To: <87fu12mnf7.fsf@concordia.ellerman.id.au>
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
next prev parent reply other threads:[~2018-07-02 17:16 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-29 18:53 [PATCH] powerpc: mpc5200: Remove VLA usage Kees Cook
2018-06-29 21:02 ` Arnd Bergmann
2018-06-29 21:44 ` Kees Cook
2018-07-02 1:33 ` Michael Ellerman
2018-07-02 15:52 ` Kees Cook
2018-07-02 17:16 ` Segher Boessenkool [this message]
2018-07-03 1:41 ` Michael Ellerman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180702171631.GA16221@gate.crashing.org \
--to=segher@kernel.crashing.org \
--cc=agust@denx.de \
--cc=arnd@arndb.de \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
--cc=paulus@samba.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.