简体   繁体   中英

Visual C++ debugger not showing return value

When I single-step with the Visual Studio debugger through the following program, no return value is shown in the "auto" window for any of the istringstream method calls.

It shows the return value for vector::size() though.

#include "stdafx.h"
#include <sstream>
#include <vector>

int main()
{
    std::vector<char>{}.size();      //<-- debugger shows return value
    std::istringstream{"x"}.get();   //<-- no return value shown
    std::istringstream{"x"}.good();  //<-- no return value shown
    std::istringstream{"x"}.tellg(); //<-- no return value shown
    return 0;
}

Of course I run this in "debug" configuration, so the compiler shouldn't be able to optimize the calls away. I created the project using console application wizard without changing any project settings afterwards.

Should I file a bug?

Edit:

Another possibly related issue: I can't F11 -step into any of the above istringstream methods. Debugger just steps over them as if I had pressed F10. Again, it works for vector::size() .

It turns out that this was an issue of missing debug symbols when dynamically linking to the VC++ runtime. After a default installation of Visual Studio 2017, for instance, debug symbols for the VC++ runtime are not available.

Possible solutions:

  • statically link to the VC++ Runtime (project properties > C/C++ > Code Generation > Runtime Library: Multithreaded-Debug)
  • enable Microsoft symbol server (Extras > Options > Debugging > Symbols > Check "Microsoft Symbol Server" and enter directory for storing symbols in the edit control below)

I think the issue did not occur for std::vector because it is header-only, so the code gets linked directly into the program executable. For the C++ stream library, much of the code actually is inside a VC runtime DLL.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM