LeetCode各种报错的含义

1.Char 5: fatal error: control may reach end of non-void function [-Wreturn-type]
}

2.AddressSanitizer: heap-buffer-overflow on address 0x602000000040 at pc 0x000000406b5e bp 0x7ffc15cc0320 sp 0x7ffc15cc0318

3.error: bad operand types for binary operator ‘&’

1.Char 5: fatal error: control may reach end of non-void function [-Wreturn-type] }

这类报错的含义是:没有考虑所有可能的返回值情况

什么意思呢,比如我们的Java程序的一个方法:

public int fun(int a)
{
    if(a>0)
    return 1
    else if(a<0)
    return -1;
}

那么如果我们的a==0那么就没有返回值,所以本方法没有考虑返回值情况

2.AddressSanitizer: heap-buffer-overflow on address 0x602000000040 at pc 0x000000406b5e bp 0x7ffc15cc0320 sp 0x7ffc15cc0318

本类报错意思是:检查了是否存在内存非法访问
就比如数组越界

3.error: bad operand types for binary operator '&'

博主的代码是这样的

if(num&1==1)

博主以为&的优先级比“==”大,实际上恰好相反,所以导致出错

博主会持续更新
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_45737068/article/details/107112552