Re: turning g_assert* into warnings



On Fri, 12 Oct 2007, Yevgen Muntyan wrote:

Hey,

Why not introduce a new check, some g_check_stuff() which would
do what you propose? And let g_assert() be what it is, a glib analog
of C assert(). When an assertion fails, you can't possibly expect the
code to function in any meaningful way, e.g.

int idx;
....
g_assert (idx >= 0);
array[idx] = 8;

you get segfault or worse here if g_assert() above fails to bring program
down, you simply can't change g_assert() now to behave in such a
different way.

please reread my reasoning about G_DISABLE_ASSERT, there already is no behavior
of g_assert() you could rely on. (and some distributions do build their
binaries with G_DISABLE_ASSERT and/or G_DISABLE_CHECKS defined).

if you really meant the above assertion as an essential program
logic part and want to depend on the program exiting before array[]
is accessed, you already have to use if (idx >= 0) g_error ("off bounds");

Best regards,
Yevgen

---
ciaoTJ



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]