code triggered a breakpoint but I set no breakpoin

2019-09-08 08:35发布

问题:

I was running a very simple program in MS visual studio 2015 and set NO breakpoint at all, but the output is:

XXXX.exe has triggered a breakpoint.

I did not set any breakpoint at all. Why would this happen? Thanks.

#include<iostream>

using namespace std;

int main() {
int a = 1;
int b = a + 1;

cout << "b is " << b << endl;

getchar();
return 1;
}

Actually the code works in cpp.sh, so I believe it must have something to do with visul studio setting

updates: I find the exact same problem here: https://software.intel.com/en-us/forums/intel-visual-fortran-compiler-for-windows/topic/590210#comment-1844444 I also installed the intel compiler. The code runs in debug-x64 mode but not debug-x86 mode. However, I could not add any breakpoints in either mode.

回答1:

I think there is still certain incompatibility between intel and MS visual studio. I uninstalled intel stuff from visual studio and now it works.



回答2:

I think you returning a 1 might cause the system to think its a failure, try either returning a 0, or doing void main() and remove the return statement.