This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

about C my references are a bit unclear re this

by my references, I read that the below (x = n if no break) is true. However should that not be the case, and Keil can change it there is a great risk, thus I'd like another read on it.

a for loop

for ( x = 0 ; x < n ; x++)
{
  .......
  if (cond) break;
  .......
}
if (x = n)
{ // there was no break


can I count on x = n if 'cond' was never met and no break happened?

If that is not something that Keil can change, but standard, I can save a bunch of flags

Erik

Parents
  • The above is a very common test, and allowed.

    Note that you have managed to do an assign in your last if test.

    No, Keil can not break this. The code optimizer may switch order of things, but (with exception of timing) must guarantee the logic sqeuence of the program.

    x != n if and only if the loop did break early.

Reply
  • The above is a very common test, and allowed.

    Note that you have managed to do an assign in your last if test.

    No, Keil can not break this. The code optimizer may switch order of things, but (with exception of timing) must guarantee the logic sqeuence of the program.

    x != n if and only if the loop did break early.

Children
No data