[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20120716143114.5ad07878@wrlaptop>
Date: Mon, 16 Jul 2012 14:31:14 -0500
From: Peter Seebach <peter.seebach@...driver.com>
To: <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 5/6] workqueue: introduce NR_WORKER_POOLS and
for_each_worker_pool()
On Fri, 13 Jul 2012 22:00:10 -0700
Linus Torvalds <torvalds@...ux-foundation.org> wrote:
> (*) Technically, "&(x)[0]" is actually a really confused way of saying
> "(x+0)" while making sure that "x" was a valid pointer.
But wait, there's more!
Should someone some day try to use an implementation with a fairly
ferocious bounds-checker, the bounds of &x[0] are the bounds of the
first member of x, while the bounds of x are... well, whatever they
were. (If x is an array, they're definitely the bounds of the whole
array. If x is a pointer to something, then it depends on how the
pointer was obtained.)
I'm not sure anyone actually has an implementation that bothers with
this level of granularity in pointers, but I am about 90% sure that an
implementation which did would be conforming. e.g.:
int a[2];
a[1] = 3; /* ok */
int *b = a;
b[1] = 3; /* ok */
int *c = &a[0];
c[1] = 3; /* bounds violation */
Note that "conforming" does not imply "could compile and run most
existing code without surprising new errors". The world is full of code
which assumes absolute identity between (a+i) and &(*(a+i)).
If the code which inspired your rant was actually doing it on purpose
to obtain this result, I shall have to buy a hat so I can eat it.
(Disclaimer: Hat must be made of something delicious.)
-s
--
Listen, get this. Nobody with a good compiler needs to be justified.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists