condition precedences in 'if'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux