Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ assert doesn't produce stack frame when I include the iostream header

I'm using Visual Studio 2013 Express for Desktop. Here is the program:

#include<cassert>
#include<iostream>

int main()
{
    int a = 1;
    assert(1 == 2);
}

When I run in Debug Mode, the assert fails and I click "Retry". Then a breakpoint is triggered, but I cannot see a in the variable list, and there is no function main() in call stack.

However, if I delete #include<iostream>, everything will be OK. I will be able to see a in the variable list, and main() will show up in call stack.

What's the problem?

like image 671
delphifirst Avatar asked Feb 19 '26 23:02

delphifirst


1 Answers

You should instruct Visual Studio 2013 to load the symbols from the MS Symbol Server. Then you get this stacktrace:

>msvcr120d.dll!_NMSG_WRITE(int rterrnum) Line 226 C
msvcr120d.dll!abort() Line 62 C
msvcr120d.dll!_wassert(const wchar_t * expr, const wchar_t * filename, unsigned int lineno) Line 156 C
ConsoleApplication1.exe!main() Line 7 C++
[External Code]

When _NMSG_WRITE is selected of course I cannot see variable a, but when selecting main() I can see the variable a in the autos and locals pane.

BTW, you should also consider updating to Visual Studio 2013 Update 2.

like image 135
Werner Henze Avatar answered Feb 22 '26 13:02

Werner Henze



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!