Reputation: 4571
For example, in the code:
bool foo = bar || baz();
the function baz()
may not be called. I've found that this is a common source of bugs for me and I'm wondering if there's a way for GCC to print a warning.
Upvotes: 3
Views: 148
Reputation: 15576
There is not a warning flag for this, it would generate a warning for too many common conditions (if(condition) bar();
, if(foo && foo->bar) baz();
, etc).
Instead, do something similar to this:
bool foo = baz() || bar;
or this:
bool foo = bar | baz();
These unconditionally call baz()
.
Upvotes: 1