RE: Is this a bug?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This was also a learning experience for me.

I have often heard students say they were told that ++x is more
efficient than x++. From looking at gcc-generated assembly language, I
knew this is not always true. It's been pointed out here that the
situation is more "interesting" than I realized.

By the way, I don't like complicated expressions because I find them
more difficult to read and change. I would've written this example as

#include <stdio.h>
int main()
{
    volatile int  x = 20,y = 35;
    x = y + x;
    x += 2;
    y += 2;
    y = y + x;
    printf("x=%d  y=%d\n" ,x,y);
    return 0;
}

Now the volatile type qualifier works independently from the algorithm,
the way god intended. (Of course, "volatile" implies we should expect
the unexpected.)




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux