0

Can anyone explain why this would fail:

assert(cap >= 0);

But this passes?

if(cap < 0)
  {
  exit(-1);
  }

That is, the assert is triggered, but if I replace it with conditional, the exit() function is never called.

Thoughts?

Thanks,

David

2
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by daviddoria
0

I don't know that this makes it much clearer, but stated another way:

double cap = some value...
assert(cap >= 0);

The assert is triggered.

double cap = same value as above

if(cap < 0)
  {
  exit(-1);
  }

I thought this would behave identically to the assert (it would quit if cap is < 0), but the assert fails at times when the if statement doesn't.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.