小编Ved*_*rad的帖子

AddressSanitizer:未知地址 0x000000000000 上的 SEGV 是什么意思?

我正在解决 leetcode 问题并收到此错误。我不知道这意味着什么,因为我对 C++ 还比较陌生。当我删除 else if 中的 else 时,它​​似乎消失了。

AddressSanitizer:DEADLYSIGNAL
=================================================================
==32==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x000000383e8c bp 0x7ffc55bebe50 sp 0x7ffc55bebd20 T0)
==32==The signal is caused by a READ memory access.
==32==Hint: address points to the zero page.
    #3 0x7f2222e3982f  (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
AddressSanitizer can not provide additional info.
==32==ABORTING
Run Code Online (Sandbox Code Playgroud)

我的代码:

class Solution {
public:
    bool isValid(string s) {
        stack<char> stk;
        int flag=1;
        for(int i=0; i< s.length();i++){
            if(s[i]=='('||s[i]=='{'||s[i]=='['){
                stk.push(s[i]);
                flag=0;
            }
            else { //if (s[i]==')'||s[i]=='}'||s[i]==']'){
                if(s[i]==')'&&stk.top()=='('){
                    stk.pop();
                    flag=1; …
Run Code Online (Sandbox Code Playgroud)

c++ runtime-error address-sanitizer

7
推荐指数
2
解决办法
5万
查看次数

标签 统计

address-sanitizer ×1

c++ ×1

runtime-error ×1