我正在使用 gdb
来调试 C++
程序。在行中
assert(prevId == GetTagIdFromState(maxState));
- 参数
prevId
值为0
; - 方法
GetTagIdFromState(maxState)
return
s50
;
调试时出现以下错误。
Assertion `prevId == GetTagIdFromState(maxState)' failed.
Program received signal SIGABRT, Aborted.
0x00007ffff6ecbba5 in raise (sig=<value optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
64 ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.
in ../nptl/sysdeps/unix/sysv/linux/raise.c
最佳答案
您的应用程序按预期工作。断言失败(因为您传递给它的值不相等,assert
宏接收 0),因此您的程序被中止。这就是断言的工作原理:
If NDEBUG is not defined, then assert checks if its argument (which must have scalar type) compares equal to zero. If it does, assert outputs implementation-specific diagnostic information on the standard error output and calls std::abort.
强调我的。
检查 this assert reference了解更多信息。
关于c++ - 调试c++ : . ./nptl/sysdeps/unix/sysv/linux/raise.c:没有这样的文件或目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13152775/