microsoft / vscode-cpptools

Official repository for the Microsoft C/C++ extension for VS Code.
Other
5.53k stars 1.56k forks source link

Stepping over std::vector<std::string> v{""} with g++-12 incorrect jumps to the end of the function #11987

Open sean-mcmanus opened 8 months ago

sean-mcmanus commented 8 months ago

Environment

Bug Summary and Steps to Reproduce

  1. Use C++ code
    #include <vector>
    #include <string>
    int main()
    {
    std::vector<std::string> v{""};
    return 0;
    }
  2. Put a breakpoint on the std::vector line and use F5.
  3. Choose to compile with the g++-12 compiler -- it doesn't repro if you switch to g++-11.
  4. Step over the std::vector function.

Bug: The stepping jumps to the bottom of the function instead of going to the next line. This occurs if additional lines of code are added as well. Stepping an extra time goes to the next line (return 0).

image

Debugger Configurations

{
  "tasks": [
    {
      "type": "cppbuild",
      "label": "C/C++: g++-12 build active file",
      "command": "/usr/bin/g++-12",
      "args": [
        "-fdiagnostics-color=always",
        "-g",
        "${file}",
        "-o",
        "${fileDirname}/${fileBasenameNoExtension}"
      ],
      "options": {
        "cwd": "${fileDirname}"
      },
      "problemMatcher": [
        "$gcc"
      ],
      "group": {
        "kind": "build",
        "isDefault": true
      },
      "detail": "Task generated by Debugger."
    }
  ],
  "version": "2.0.0"
}

launch.json is the default generated with F5.

Debugger Logs

...

Other Extensions

No response

Additional Information

I didn't find this bug -- it was found by an "internal team".

James-Bonner commented 1 month ago

Hi Sean,

I've been encountering this exact issue, just in a completely different context - Visual Studio 2022 with MSVC 2022, so it may not be a vscode-cpptools issue. Did you ever get any additional insights?

sean-mcmanus commented 1 month ago

@James-Bonner The debugger implementation for g++ is different for cl.exe, so your issue probably has a different root cause. You may want to file a new issue (or an issue with VS 2022 if you repro it there). And I didn't get any more insights into the g++ debugger issue.