mirror of https://github.com/svaarala/duktape.git
Browse Source
Unused variables in some option combinations. Some of these were caused by having -DDUK_OPT_DEBUG but no debug print options. The GCC -O4 array subscript warning seems spurious and is probably caused by GCC not being 100% sure 'count' is always valid. The call sites for duk__advance_chars() have a variety of argument values, including those computed using shifts etc. Add an explicit check for the valid range which silences the GCC error. The check also protects against regressions that would cause an invalid count to be used. With the check in place, potentially memory unsafe behavior will now cause an internal error instead. If the form DUK_ASSERT(x >= 0 && x < y) is used, gcc will cause a spurious warning: duk_api_stack.c:149:33: error: assuming signed overflow does not occur when assuming that (X - c) > X is always false [-Werror=strict-overflow] duk_error.h:131:8: note: in definition of macro ‘DUK_ASSERT’ By breaking down the assert into two, i.e. DUK_ASSERT(x >= 0) and DUK_ASSERT(x < y) the warning disappears.v1.0-maintenance
Sami Vaarala
10 years ago
5 changed files with 30 additions and 9 deletions
Loading…
Reference in new issue