condition precedences in 'if'

mahmoodn nt_mahmood@yahoo.com
Thu Aug 12 10:00:00 GMT 2010


Dear all,

First consider this:
bool flag = false;
while (condition) {
   ...
   if ( !flag && ANOTHER_CONDITION ) {
      ....
   }
}
If the "while" loop iterates for 10 times, the both flag and
ANOTHER_CONDITION are checked 10 times.

Now consider this:
bool flag = false;
while (condition) {
   ...
   if ( !flag && ANOTHER_CONDITION ) {
      ....
      flag = true;
   }
}
If the "while" loop iterates for 10 times and in the first iteration "flag =
true;" is executed, then how many times, ANOTHER_CONDITION is checked? 1 or
10?

How does GCC-4.1.3 act to condition precedences? 
-- 
View this message in context: http://old.nabble.com/condition-precedences-in-%27if%27-tp29415495p29415495.html
Sent from the gcc - Help mailing list archive at Nabble.com.



More information about the Gcc-help mailing list