From: Linus Torvalds <torvalds@osdl.org>
To: linux-kernel@vger.kernel.org
Subject: Re: Sparse warning: bitmap.h: bad constant expression
Date: Tue, 02 Sep 2003 09:45:31 -0700 [thread overview]
Message-ID: <bj2hfc$a4c$1@build.pdx.osdl.net> (raw)
In-Reply-To: 16212.28592.322946.64754@gargle.gargle.HOWL
Mikael Pettersson wrote:
>
> If data is a local variable then this is perfectly valid example of a
> C99 variable-length array (VLA). This works at least with gcc-2.95.3
> and newer, and gcc handles it by itself w/o calling alloca().
"alloca()" is not a function. It's a compiler intrisic, and Jörn is correct:
a variable-length array is _exactly_ the same as the historic "alloca()"
thing, and will generate the same code (modulo syntactic changes due to the
fact that one generates a pointer and the other generates an array).
And yes, it is legal in C99. However, it's not supposed to be legal in the
kernel, because it makes it impossible to check certain trivial things
about stack usage automatially. In particular, it totally breaks the
"objdump + grep" approach for finding bad stack users.
Also, trivial bugs (like not checking ranges etc) cause total stack
corruption with the feature, which means that such a kernel bug gets really
hard to track down.
So I consider the sparse warning to be appropriate.
That said, I do want to have a code-generation back-end for sparse some day,
if only because it's the only practical way to validate the front-end (ie
seeing if the back-end generates code that actually works - performance
doesn't matter). So I'd like to eventually extend sparse to handle variable
arrays, but I'd still want to have a flag to warn about them.
Linus
next prev parent reply other threads:[~2003-09-02 16:49 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-09-01 19:59 Sparse warning: bitmap.h: bad constant expression Petri Koistinen
2003-09-02 1:57 ` Dave Olien
2003-09-02 9:56 ` Jörn Engel
2003-09-02 10:23 ` Mikael Pettersson
2003-09-02 10:54 ` Jörn Engel
2003-09-02 16:45 ` Linus Torvalds [this message]
2003-09-02 20:08 ` Jörn Engel
2003-09-02 17:38 ` Dave Olien
2003-09-02 20:11 ` Jörn Engel
2003-09-02 17:22 ` William Lee Irwin III
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='bj2hfc$a4c$1@build.pdx.osdl.net' \
--to=torvalds@osdl.org \
--cc=linux-kernel@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox