Stephan Bergmann wrote:
3 OSL_VERIFY
On unxsoli4 and unxsols4 PRODUCT builds, OSL_VERIFY(a == b) causes a
spurious warning "The result of a comparison is unused" (because the
argument of OSL_VERIFY is always executed, even for OSL_DEBUG_LEVEL ==
0). Instead of disabling the corresponding unxsoli4 and unxsols4
warning, I would vote to change code
OSL_VERIFY(e);
to
if (!e) {
OSL_ASSERT(false);
}
I disagree. Cluttering the code with extraneous control structures
and/or temporary variables for debug output makes the code less readable
and is easier to get wrong during maintenance.
I also hope that eventually, when our assertion macros are overhauled,
we make use of the capabilities of the preprocessor to include the
failed condition in the assertion output (like most implementations of C
assert() do). When we do that, using a meaningful condition in the
argument to the diagnostic macro instead of 'false' will produce more
meaningful diagnostic output. (For existing instances of
OSL_ASSERT(false), you won't get worse than the current "null" message
anyhow).
<offtopic>
BTW: IMHO if there are many instances of OSL_ASSERT(false), that
indicates to me that we need a OSL_ASSERT_ALWAYS() or OSL_ERROR().
</offtopic>
(and thus work around the warning) on the ground that OSL_VERIFY is
dangerous and confusing---unlike the other OSL diagnose functions, it
*does* evaluate its argument for OSL_DEBUG_LEVEL == 0. In the interest
of the "least surprise" principle, we IMO should deprecate OSL_VERIFY
and replace all its occurrences as described above.
Why is it confusing, if a macro that has the very purpose of always
evaluating the expression it contains (and asserts about) does its job.
AFAIK that is the one differentiator to OSL_ASSERT/ENSURE.
If people use it for expressions without side effects that is an
education problem.
If there is a range of different diagnostic macros available I'd expect
them to have different semantics. And before using one of them a
developer should know what it does.
Ciao, Jörg
--
Joerg Barfurth Sun Microsystems - Desktop - Hamburg
>>>>>>>>>>>>>>>>>> using std::disclaimer <<<<<<<<<<<<<<<<<<<<<<<
Software Engineer [EMAIL PROTECTED]
OpenOffice.org Configuration http://util.openoffice.org
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]