Here, bar() must be called regardless of whether debug is enabled, but we can check whether rc is valid only in debug. Since bar() must be called, its result must be stored to a variable, which can never be used.
The definition of assert could be improved so that:
Suppose that it is possible for a function to fail at the end of a
void
function An assert can be used to catch this, but it's not usable otherwise.Here,
bar()
must be called regardless of whether debug is enabled, but we can check whetherrc
is valid only in debug. Sincebar()
must be called, its result must be stored to a variable, which can never be used.The definition of
assert
could be improved so that:Alternatively, it could be defined like this: