vector subscript out of range line 932 does not stop

Asked 1 years ago, Updated 1 years ago, 79 views

The "vector subscription out of range line 932" dialog appears, and the application is running.Please tell me when this happens.
"Also, if it happens again, I would like to select ""retry"" and look at the call history in Debug, so please let me know if there is any other good way."
The environment is Win8 Pro VS2010 C++

c++ visual-studio

2022-09-30 21:00

1 Answers

If you look at the VC++ vector source, you can see that vector::operator[](size_type) is out of range.

No, I noticed that the dialog came out (including ignoring) and the application was running without selecting anything.

Isn't a different thread working than the one that caused the error?
In the sample program below, the sub-threads will continue to move.

#include<Windows.h>
# include <process.h>
# include <vector>
# include <iostream>

unsigned int__stdcall sub_thread_func (void*)
{
    for(unsigned inti=0;i<100;++i){
        std::cerr<<"subthreadi="<<i<<std::endl;
        Sleep (1000);
    }

    _endthreadex(0);
    return 0;
}

int_tmain(intargc,_TCHAR*argv[])
{
    HANDLE sub_thread_handle=(HANDLE)_beginthreadex (NULL, 0, & sub_thread_func, NULL, 0, NULL);
    if(!sub_thread_handle){
        error("subthread");
        return1;
    }
    while(true){
        DWORD wait_result = WaitForSingleObject(sub_thread_handle, 1000);
        if(wait_result!=WAIT_TIMEOUT){
            break;  
        }
        std::vector<int>vec;
        inti=vec[0];
    }
    return 0;
}


2022-09-30 21:00

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.