Reputation: 1054
g++ 4.8.2 (cygwin)
The testMarkListIO() statement is executed before the testListIO() statement. Is there any reason for this?
bool testIO() {
bool flag = true;
time_t rawtime;
struct tm * ptm;
time ( &rawtime );
ptm = gmtime ( &rawtime );
stringstream pretty;
pretty << "TestIOLog_" << ptm->tm_yday
<< ptm->tm_hour
<< ptm->tm_min
<< ptm->tm_sec
<< ".log";
filename = pretty.str();
flag = (testListIO())? flag: false;
flag = (testMarkListIO())? flag: false;
flag = (testDescriptorListIO())? flag: false;
flag = (testUserDataIO())? flag: false;
flag = (testInclude())? flag: false;
sleep(1);
testResultOutput("Test I/O", flag);
return flag;
}; // bool testIO()
Upvotes: 0
Views: 174
Reputation: 1054
Bonehead question. Sorry. The correct answer is that I made an output error. I output the wrong message. Sigh. Never trust a programmer for something a child can do.
Sorry, sorry, sorry.
art
Upvotes: 0
Reputation: 340208
For these statements (and the other similar ones):
flag = (testListIO())? flag: false;
flag = (testMarkListIO())? flag: false;
If the functions are inlined and the compiler can a tell that there are no side effects other than setting flag
, it is free to order those statements however it sees fit as long as the value passed to testResultOutput()
and returned from the function are are the same as what would have happened if the statements were executed strictly in order.
This is commonly known as the "as if" rule. Essentially, the compiler if free to execute things however it wants if the visible results are the same as if it executed them according to the source code order.
Upvotes: 1