lkml.org 
[lkml]   [2005]   [Nov]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    From
    SubjectRe: typedefs and structs
    Date
    On Nov 10, 2005, at 08:27:18, Nikita Danilov wrote:
    > extern declaration in your version of bar() cannot refer to the
    > automatic variable myvar in foo().

    int foo;

    void bar(const int *local_var) {
    foo = *local_var + 1;
    }

    void show(void) {
    printf("%d\n", foo);
    bar(&foo);
    printf("%d\n", foo);
    }

    If GCC thought it could arbitrarily cache anything it wanted to, then
    code like this would die. There is a whole mess of code in GCC
    designed specifically to watch for and avoid aliasing issues like these.

    Cheers,
    Kyle Moffett

    --
    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are, by
    definition, not smart enough to debug it.
    -- Brian Kernighan


    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

    \
     
     \ /
      Last update: 2005-11-10 20:24    [W:2.715 / U:0.096 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site