g_return_if_fail() breakage
- From: Daniel Elstner <daniel elstner gmx net>
- To: gtk-devel-list gnome org
- Subject: g_return_if_fail() breakage
- Date: 26 Nov 2002 02:40:12 +0100
Hi,
I just had a look at the new definitions of G_[UN]LIKELY(),
g_return_if_fail() and friends. If optimization is disabled, the
following definitions are used:
#define G_LIKELY(expr) expr
#define G_UNLIKELY(expr) expr
Now consider this:
#define g_return_if_fail(expr) G_STMT_START{ \
if (!G_LIKELY (expr)) \
{ \
Which effectively results in (!expr). Ouch.
To fix this either g_return_if_fail() or G_LIKELY() should add parens.
The latter is probably the safest option, even though we'd definitely
lose the warning feature with -O0 or other compilers than GCC.
--Daniel
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]