[lkml]   [2012]   [Jul]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectRe: [PATCH 5/6] workqueue: introduce NR_WORKER_POOLS and for_each_worker_pool()
    On Fri, 13 Jul 2012 22:00:10 -0700
    Linus Torvalds <> 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.)

    Listen, get this. Nobody with a good compiler needs to be justified.

     \ /
      Last update: 2012-07-16 22:21    [W:0.022 / U:9.828 seconds]
    ©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site