Guys in one of excersises (ch.5,e.8) from TC++PL Bjarne asks to do following:
'"Run some tests to see if your compiler really generates equivalent code for iteration using pointers and iteration using indexing. If different degrees of optimization can be requested, see if and how that affects the quality of the generated code"'
Any idea how to eat it and with what?
You want to write code something like this:
int a[] = {1,2,3,4};
int n = 0;
for ( int i = 0; i < 4; i++ ) {
n += a[i];
}
int * p = a;
for ( int i = 0; i < 4; i++ ) {
n += *p++;
}
Then you need to compile it with compiler options that gets your compiler to emit assembly language, and take a look at it. It's also instructive to do this both with and without optimisations turned on.