R
Ralf Goertz
(second repost, there seem to be problems)
Hi,
this might be g++-related but it raises a general question.
#include <iostream>
using namespace std;
bool getValue(int& val){
val=int(42);
return true;
}
int main(){
int i(0);
cout<< i<<" "<<getValue(i)<<" value "<<i<<endl; // (*)
}
Compiled with optimization (-O3) this yields the output
Without optimization it gives
I had expected
Do I have to read the line (*) from right to left? But that seems odd
since "endl" is at the end of the output.
Ralf
Hi,
this might be g++-related but it raises a general question.
#include <iostream>
using namespace std;
bool getValue(int& val){
val=int(42);
return true;
}
int main(){
int i(0);
cout<< i<<" "<<getValue(i)<<" value "<<i<<endl; // (*)
}
Compiled with optimization (-O3) this yields the output
42 1 value 42
Without optimization it gives
42 1 value 0
I had expected
0 1 value 42
Do I have to read the line (*) from right to left? But that seems odd
since "endl" is at the end of the output.
Ralf