stv) ////////////// 100::if(abc) /////////-6ren">
gpt4 book ai didi

c - 为什么编译的时候会出现如下错误

转载 作者:太空宇宙 更新时间:2023-11-04 06:08:27 25 4
gpt4 key购买 nike

作为我程序的一部分,我使用了以下代码:

///////////////
98:::printf("%d",abc->stv)
//////////////
100::if(abc)
//////////////

(产生了以下错误)

Possible null pointer dereference: abc - otherwise it is redundant to check if abc is null at line 100

最佳答案

if (abc) 测试 abc 是否为空指针。

编译器警告您,您已经假设 abc 不是空指针(通过在第 98 行取消引用它),这意味着要么

  • if (abc) 测试是多余的(因为它永远不会为真)或者
  • 第 98 行对 abc 的取消引用可能不正确,因为 abc 实际上可能为 null。

关于c - 为什么编译的时候会出现如下错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5228514/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com