This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Is this a bug?


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 Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]