GDB尝试获取不在内存中的值的地址

时间:2018-03-20 05:01:08

标签: c++ c++11 gdb memory-address

我有以下if语句(c ++)应该创建一个错误的条件返回一个正确的值:

(gdb) print (start0 < board.size() && start1 < board[0].size() - ship.GetSize() && ori=='h')
$7 = false
(gdb) print (start0 < board.size() && start1 < board[0].size() && ori=='n')
$8 = true

但是当我尝试测试其中两个值时,我收到以下错误:

(gdb) print (start0 < board.size() && start1 < board[0].size() - ship.GetSize() && ori=='h') || (start0 < board.size() && start1 < board[0].size() && ori=='n')
Attempt to take address of value not located in memory.

这会导致他们无法通过的整个if语句。我经过大量测试后100%确定这些值是正确的,我只是遗漏了什么?这是代码所在的if语句:

if ((start0 < board.size() - ship.GetSize() && start1 < board[0].size() && ori=='v') ||
    (start0 < board.size() && start1 < board[0].size() - ship.GetSize() && ori=='h') ||
    (start0 < board.size() && start1 < board[0].size() && ori=='n')){

0 个答案:

没有答案
相关问题