为什么会出现此警告?如果我检查界限,这并不是一个真正的假设。以及如何解决?
如果num_actions_to_skip
设置为 1,而不是 2,则错误消失。
谢谢
error: assuming signed overflow does not occur when assuming that (X - c) <= X is always true [-Werror=strict-overflow]
cc1plus: all warnings being treated as errors
上if (loc >= 0 && loc < action_list.count()) {
const QList<QAction *> &action_list = tool_menu->actions();
static const int num_actions_to_skip = 2;
const int loc = action_list.count() - num_actions_to_skip;
if (loc >= 0 && loc < action_list.count()) {
tool_menu->insertAction(action_list.at(loc),
action);
}
它始于
Q_ASSERT_X(i >= 0 && i < p.size()
在 qlist.h:454,它执行相同的检查,并且也抛出此错误,只需
tool_menu->insertAction(action_list.at(action_list.count() - 2),
action);