microsoft / microsoft/vscode-cpptools

Watch Window expressions can fail due to `permissive-` compiler flag

Open
#14,455 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

debugger
Dominant language
TypeScript
Stars
6.2k
Forks
1.7k
Avg merge
14h 46m
Merged PRs (30d)
61

Description

Environment
  • OS and Version: Microsoft Windows 10 Pro (Version 10.0.19045 Build 19045)
  • VS Code Version: 1.120.0
  • C/C++ Extension Version: 1.32.2
  • Visual Studio Version: Community 2026 version 18.5.2
Bug Summary and Steps to Reproduce

Bug Summary:
Certain expressions have started failing to display in the Watch Window for me - please see attached repro code and instructions, thanks!

Image

Steps to reproduce:

  1. Requires Visual Studio installation to call cl.exe
  2. Download and unzip example code: VSCodeWatchWindowTest.zip
  3. Launch VS Code from x64 Native Tools Command Prompt for VS
  4. Open example code
  5. Run default build task
  6. Place breakpoint in main.cpp on line 19
  7. Start debugging
  8. Look in locals window - result evaluates as An unspecified error has occurred. If you add it to the watch window it is shown as identifier "result" is undefined
    Expected behavior:
    Contents of result are displayed properly
Debugger Configurations
tasks.json:

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build",
            "type": "shell",
            "command": "./build.bat",
            "problemMatcher": [
                "$msCompile"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "presentation": {
                "clear": true
            }
        },
    ]
}

launch.json:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(Windows) Launch",
            "type": "cppvsdbg",
            "request": "launch",
            "program": "${workspaceFolder}/build/main.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "logging": { 
                "engineLogging": true,
                "trace": true,
                "traceResponse": true
            },
            "console": "internalConsole"
        }
    ]
}
Debugger Logs
<- (E) {"seq":3,"type":"event","event":"output","body":{"category":"console","output":"------------------------------------------------------------------------------\nYou may only use the C/C++ Extension for Visual Studio Code with Visual Studio\nCode, Visual Studio or Visual Studio for Mac software to help you develop and\ntest your applications.\n------------------------------------------------------------------------------\n","severity":"ok"}}
------------------------------------------------------------------------------
You may only use the C/C++ Extension for Visual Studio Code with Visual Studio
Code, Visual Studio or Visual Studio for Mac software to help you develop and
test your applications.
------------------------------------------------------------------------------
<- (R) {"seq":5,"type":"response","request_seq":2,"success":true,"command":"launch"}
-> (C) {"type":"response","seq":1,"command":"handshake","request_seq":2,"success":true,"body":{"signature":"625UmCEnCH6afVSxs9jB9jEatNAO2Zna7Ez9NQ637quWD0="}}
<- (E) {"seq":8,"type":"event","event":"initialized","body":{}}
-> (C) {"command":"setBreakpoints","arguments":{"source":{"name":"main.cpp","path":"c:\\Users\\Kevin\\Documents\\Programming\\VSCodeWatchWindowTest\\main.cpp"},"lines":[19],"breakpoints":[{"line":19}],"sourceModified":false},"type":"request","seq":3}
<- (E) {"seq":11,"type":"event","event":"output","body":{"category":"telemetry","output":"vs/diagnostics/debugger/vsdbg/BreakpointAdded","data":{"VS.Diagnostics.Debugger.vsdbg.OSFamily":"Windows","VS.Diagnostics.Debugger.vsdbg.Version":"17.13.20115.1 commit:2813ca575686dd74c298baf93407e693cefabef1","VS.Diagnostics.Debugger.vsdbg.BreakpointAdded.HasHitCount":false,"VS.Diagnostics.Debugger.vsdbg.WindowsVersion":"10.0.19045","VS.Diagnostics.Debugger.vsdbg.AdapterId":"cppvsdbg","VS.Diagnostics.Debugger.vsdbg.BreakpointAdded.BreakpointType":"Source","VS.Diagnostics.Debugger.vsdbg.BreakpointAdded.HasLogMessage":false,"VS.Diagnostics.Debugger.vsdbg.BreakpointAdded.HasCondition":false}}}
<- (R) {"seq":13,"type":"response","request_seq":3,"success":true,"command":"setBreakpoints","body":{"breakpoints":[{"id":1,"verified":false,"message":"The breakpoint is pending and will be resolved when debugging starts.","line":19}]}}
-> (C) {"command":"setFunctionBreakpoints","arguments":{"breakpoints":[]},"type":"request","seq":4}
<- (R) {"seq":16,"type":"response","request_seq":4,"success":true,"command":"setFunctionBreakpoints","body":{"breakpoints":[]}}
-> (C) {"command":"setInstructionBreakpoints","arguments":{"breakpoints":[]},"type":"request","seq":5}
<- (R) {"seq":19,"type":"response","request_seq":5,"success":true,"command":"setInstructionBreakpoints","body":{"breakpoints":[]}}
-> (C) {"command":"setExceptionBreakpoints","arguments":{"filters":[],"filterOptions":[]},"type":"request","seq":6}
<- (R) {"seq":22,"type":"response","request_seq":6,"success":true,"command":"setExceptionBreakpoints","body":{}}
-> (C) {"command":"configurationDone","type":"request","seq":7}

<- (E) {"seq":25,"type":"event","event":"output","body":{"category":"telemetry","output":"VS/Diagnostics/Debugger/vsdbg/ProcessCreate","data":{"VS.Diagnostics.Debugger.vsdbg.OSFamily":"Windows","VS.Diagnostics.Debugger.vsdbg.Version":"17.13.20115.1 commit:2813ca575686dd74c298baf93407e693cefabef1","VS.Diagnostics.Debugger.vsdbg.WindowsVersion":"10.0.19045","VS.Diagnostics.Debugger.vsdbg.TargetArchitecture":"AMD64"}}}
<- (E) {"seq":27,"type":"event","event":"process","body":{"name":"C:\\Users\\Kevin\\Documents\\Programming\\VSCodeWatchWindowTest\\build\\main.exe","systemProcessId":17092,"startMethod":"launch","pointerSize":64}}
<- (E) {"seq":29,"type":"event","event":"breakpoint","body":{"reason":"changed","breakpoint":{"id":1,"verified":false,"message":"No symbols have been loaded for this document.","line":19}}}
<- (R) {"seq":31,"type":"response","request_seq":7,"success":true,"command":"configurationDone"}
-> (C) {"command":"threads","type":"request","seq":8}
<- (R) {"seq":34,"type":"response","request_seq":8,"success":true,"command":"threads","body":{"threads":[]}}
<- (E) {"seq":36,"type":"event","event":"output","body":{"category":"console","output":"main.exe (17092): Loaded 'C:\\Users\\Kevin\\Documents\\Programming\\VSCodeWatchWindowTest\\build\\main.exe'. Symbols loaded.\n","outputRoutingOption":"outputChannel"}}
main.exe (17092): Loaded 'C:\Users\Kevin\Documents\Programming\VSCodeWatchWindowTest\build\main.exe'. Symbols loaded.
<- (E) {"seq":38,"type":"event","event":"module","body":{"reason":"new","module":{"id":1000,"name":"main.exe","path":"C:\\Users\\Kevin\\Documents\\Programming\\VSCodeWatchWindowTest\\build\\main.exe","isUserCode":true,"symbolStatus":"Symbols loaded.","symbolFilePath":"C:\\Users\\Kevin\\Documents\\Programming\\VSCodeWatchWindowTest\\build\\main.pdb"}}}
<- (E) {"seq":40,"type":"event","event":"breakpoint","body":{"reason":"changed","breakpoint":{"id":1,"verified":true,"source":{"name":"main.cpp","path":"C:\\Users\\Kevin\\Documents\\Programming\\VSCodeWatchWindowTest\\main.cpp","sourceReference":0,"checksums":[{"algorithm":"SHA256","checksum":"5916b8062e703c3220e18ca4d4c4e11e7ed826dc9fc4a89fb302ab90b270a1ee"}]},"line":19,"endLine":19,"instructionReference":"0x00007FF67163102B","offset":0}}}
<- (E) {"seq":42,"type":"event","event":"thread","body":{"reason":"started","threadId":12696}}
<- (E) {"seq":44,"type":"event","event":"output","body":{"category":"console","output":"main.exe (17092): Loaded 'C:\\Windows\\System32\\ntdll.dll'. \n","outputRoutingOption":"outputChannel"}}
main.exe (17092): Loaded 'C:\Windows\System32\ntdll.dll'. 
<- (E) {"seq":46,"type":"event","event":"module","body":{"reason":"new","module":{"id":1001,"name":"ntdll.dll","path":"C:\\Windows\\System32\\ntdll.dll","isUserCode":false,"version":"10.0.19041.7291 (WinBuild.160101.0800)","symbolStatus":"Cannot find or open the PDB file."}}}
<- (E) {"seq":48,"type":"event","event":"output","body":{"category":"console","output":"main.exe (17092): Loaded 'C:\\Windows\\System32\\kernel32.dll'. \n","outputRoutingOption":"outputChannel"}}
main.exe (17092): Loaded 'C:\Windows\System32\kernel32.dll'. 
<- (E) {"seq":50,"type":"event","event":"module","body":{"reason":"new","module":{"id":1002,"name":"kernel32.dll","path":"C:\\Windows\\System32\\kernel32.dll","isUserCode":false,"version":"10.0.19041.7291 (WinBuild.160101.0800)","symbolStatus":"Cannot find or open the PDB file."}}}
<- (E) {"seq":52,"type":"event","event":"output","body":{"category":"console","output":"main.exe (17092): Loaded 'C:\\Windows\\System32\\KernelBase.dll'. \n","outputRoutingOption":"outputChannel"}}
main.exe (17092): Loaded 'C:\Windows\System32\KernelBase.dll'. 
<- (E) {"seq":54,"type":"event","event":"module","body":{"reason":"new","module":{"id":1003,"name":"KernelBase.dll","path":"C:\\Windows\\System32\\KernelBase.dll","isUserCode":false,"version":"10.0.19041.7291 (WinBuild.160101.0800)","symbolStatus":"Cannot find or open the PDB file."}}}
<- (E) {"seq":56,"type":"event","event":"thread","body":{"reason":"started","threadId":14600}}
<- (E) {"seq":58,"type":"event","event":"thread","body":{"reason":"started","threadId":11936}}
<- (E) {"seq":60,"type":"event","event":"output","body":{"category":"console","output":"main.exe (17092): Loaded 'C:\\Windows\\System32\\vcruntime140d.dll'. \n","outputRoutingOption":"outputChannel"}}

main.exe (17092): Loaded 'C:\Windows\System32\vcruntime140d.dll'. 
<- (E) {"seq":62,"type":"event","event":"module","body":{"reason":"new","module":{"id":1004,"name":"vcruntime140d.dll","path":"C:\\Windows\\System32\\vcruntime140d.dll","isUserCode":false,"version":"14.50.35719.0","symbolStatus":"Cannot find or open the PDB file."}}}
<- (E) {"seq":64,"type":"event","event":"output","body":{"category":"console","output":"main.exe (17092): Loaded 'C:\\Windows\\System32\\ucrtbased.dll'. \n","outputRoutingOption":"outputChannel"}}
main.exe (17092): Loaded 'C:\Windows\System32\ucrtbased.dll'. 
<- (E) {"seq":66,"type":"event","event":"module","body":{"reason":"new","module":{"id":1005,"name":"ucrtbased.dll","path":"C:\\Windows\\System32\\ucrtbased.dll","isUserCode":false,"version":"10.0.26100.7705 (WinBuild.160101.0800)","symbolStatus":"Cannot find or open the PDB file."}}}
<- (E) {"seq":68,"type":"event","event":"thread","body":{"reason":"started","threadId":19060}}
<- (E) {"seq":70,"type":"event","event":"output","body":{"category":"telemetry","output":"VS/Diagnostics/Debugger/vsdbg/Launch","data":{"VS.Diagnostics.Debugger.vsdbg.OSFamily":"Windows","VS.Diagnostics.Debugger.vsdbg.Version":"17.13.20115.1 commit:2813ca575686dd74c298baf93407e693cefabef1","VS.Diagnostics.Debugger.vsdbg.VisualizerFileUsed":false,"VS.Diagnostics.Debugger.vsdbg.WindowsVersion":"10.0.19045","VS.Diagnostics.Debugger.vsdbg.TargetType":"Live","VS.Diagnostics.Debugger.vsdbg.AdapterId":"cppvsdbg","VS.Diagnostics.Debugger.vsdbg.SourceFileMappings":0,"VS.Diagnostics.Debugger.vsdbg.Launch.DebuggerStartTime":187}}}
<- (E) {"seq":72,"type":"event","event":"stopped","body":{"reason":"breakpoint","threadId":12696,"allThreadsStopped":true,"hitBreakpointIds":[1],"source":{"name":"main.cpp","path":"C:\\Users\\Kevin\\Documents\\Programming\\VSCodeWatchWindowTest\\main.cpp"},"line":19,"column":0}}
-> (C) {"command":"threads","type":"request","seq":9}
<- (R) {"seq":75,"type":"response","request_seq":9,"success":true,"command":"threads","body":{"threads":[{"id":12696,"name":"Main Thread"},{"id":14600,"name":"ntdll.dll thread"},{"id":11936,"name":"ntdll.dll thread"},{"id":19060,"name":"ntdll.dll thread"}]}}
-> (C) {"command":"stackTrace","arguments":{"threadId":12696,"startFrame":0,"levels":20},"type":"request","seq":10}
<- (R) {"seq":78,"type":"response","request_seq":10,"success":true,"command":"stackTrace","body":{"stackFrames":[{"id":1000,"name":"main.exe!doFoo(vec3 pos) Line 19","source":{"name":"main.cpp","path":"C:\\Users\\Kevin\\Documents\\Programming\\VSCodeWatchWindowTest\\main.cpp","sourceReference":0,"checksums":[{"algorithm":"SHA256","checksum":"5916b8062e703c3220e18ca4d4c4e11e7ed826dc9fc4a89fb302ab90b270a1ee"}]},"line":19,"column":1,"endLine":19,"endColumn":0,"instructionPointerReference":"0x00007FF67163102B","moduleId":1000},{"id":1001,"name":"main.exe!doBar(Bar * bar) Line 22","source":{"name":"main.cpp","path":"C:\\Users\\Kevin\\Documents\\Programming\\VSCodeWatchWindowTest\\main.cpp","sourceReference":0,"checksums":[{"algorithm":"SHA256","checksum":"5916b8062e703c3220e18ca4d4c4e11e7ed826dc9fc4a89fb302ab90b270a1ee"}]},"line":22,"column":1,"endLine":22,"endColumn":0,"instructionPointerReference":"0x00007FF67163109B","moduleId":1000},{"id":1002,"name":"main.exe!main() Line 28","source":{"name":"main.cpp","path":"C:\\Users\\Kevin\\Documents\\Programming\\VSCodeWatchWindowTest\\main.cpp","sourceReference":0,"checksums":[{"algorithm":"SHA256","checksum":"5916b8062e703c3220e18ca4d4c4e11e7ed826dc9fc4a89fb302ab90b270a1ee"}]},"line":28,"column":1,"endLine":28,"endColumn":0,"instructionPointerReference":"0x00007FF671631110","moduleId":1000},{"id":1003,"name":"main.exe!invoke_main() Line 79","source":{"name":"exe_common.inl","path":"D:\\a\\_work\\1\\s\\src\\vctools\\crt\\vcstartup\\src\\startup\\exe_common.inl","sourceReference":0,"checksums":[{"algorithm":"SHA256","checksum":"06302037b260f066fed492d8bb29ef08d9906fd3afb9dd34a71b9c4c537a9dbc"}]},"line":79,"column":1,"endLine":79,"endColumn":0,"instructionPointerReference":"0x00007FF6716315C9","moduleId":1000},{"id":1004,"name":"main.exe!__scrt_common_main_seh() Line 288","source":{"name":"exe_common.inl","path":"D:\\a\\_work\\1\\s\\src\\vctools\\crt\\vcstartup\\src\\startup\\exe_common.inl","sourceReference":0,"checksums":[{"algorithm":"SHA256","checksum":"06302037b260f066fed492d8bb29ef08d9906fd3afb9dd34a71b9c4c537a9dbc"}]},"line":288,"column":1,"endLine":288,"endColumn":0,"instructionPointerReference":"0x00007FF6716314E2","moduleId":1000},{"id":1005,"name":"main.exe!__scrt_common_main() Line 331","source":{"name":"exe_common.inl","path":"D:\\a\\_work\\1\\s\\src\\vctools\\crt\\vcstartup\\src\\startup\\exe_common.inl","sourceReference":0,"checksums":[{"algorithm":"SHA256","checksum":"06302037b260f066fed492d8bb29ef08d9906fd3afb9dd34a71b9c4c537a9dbc"}]},"line":331,"column":1,"endLine":331,"endColumn":0,"instructionPointerReference":"0x00007FF67163139E","moduleId":1000},{"id":1006,"name":"main.exe!mainCRTStartup(void * __formal) Line 17","source":{"name":"exe_main.cpp","path":"D:\\a\\_work\\1\\s\\src\\vctools\\crt\\vcstartup\\src\\startup\\exe_main.cpp","sourceReference":0,"checksums":[{"algorithm":"SHA256","checksum":"f4f590f440ba7bf9472debd09278df41dbb87be3e4ee224be6fc2b2edb515f7b"}]},"line":17,"column":1,"endLine":17,"endColumn":0,"instructionPointerReference":"0x00007FF67163163E","moduleId":1000},{"id":1007,"name":"kernel32.dll!00007fff4dfd7374()","line":0,"column":0,"instructionPointerReference":"0x00007FFF4DFD7374","moduleId":1002},{"id":1008,"name":"ntdll.dll!00007fff4f73cc91()","line":0,"column":0,"instructionPointerReference":"0x00007FFF4F73CC91","moduleId":1001}],"totalFrames":9}}
-> (C) {"command":"threads","type":"request","seq":11}

<- (R) {"seq":81,"type":"response","request_seq":11,"success":true,"command":"threads","body":{"threads":[{"id":12696,"name":"Main Thread"},{"id":14600,"name":"ntdll.dll thread"},{"id":11936,"name":"ntdll.dll thread"},{"id":19060,"name":"ntdll.dll thread"}]}}
-> (C) {"command":"evaluate","arguments":{"expression":"result","frameId":1000,"context":"watch"},"type":"request","seq":12}
<- (E) {"seq":84,"type":"event","event":"output","body":{"category":"telemetry","output":"VS/Diagnostics/Debugger/vsdbg/Evaluate","data":{"VS.Diagnostics.Debugger.vsdbg.Evaluation.IsError":true,"VS.Diagnostics.Debugger.vsdbg.Evaluation.Duration":15,"VS.Diagnostics.Debugger.vsdbg.OSFamily":"Windows","VS.Diagnostics.Debugger.vsdbg.Version":"17.13.20115.1 commit:2813ca575686dd74c298baf93407e693cefabef1","VS.Diagnostics.Debugger.vsdbg.WindowsVersion":"10.0.19045","VS.Diagnostics.Debugger.vsdbg.AdapterId":"cppvsdbg"}}}
<- (R) {"seq":86,"type":"response","request_seq":12,"success":true,"command":"evaluate","body":{"result":"identifier \"result\" is undefined","presentationHint":{"attributes":["readOnly","failedEvaluation"]},"variablesReference":0}}
-> (C) {"command":"scopes","arguments":{"frameId":1000},"type":"request","seq":13}
<- (R) {"seq":89,"type":"response","request_seq":13,"success":true,"command":"scopes","body":{"scopes":[{"name":"Locals","variablesReference":1000,"expensive":false},{"name":"Registers","presentationHint":"registers","variablesReference":1001,"expensive":true}]}}
-> (C) {"command":"variables","arguments":{"variablesReference":1000},"type":"request","seq":14}
<- (R) {"seq":92,"type":"response","request_seq":14,"success":true,"command":"variables","body":{"variables":[{"name":"pos","value":"{x=0.00000000 y=0.00000000 z=0.00000000 }","type":"vec3","presentationHint":{"kind":"data","attributes":["readOnly"]},"evaluateName":"pos","variablesReference":1002},{"name":"result","value":"An unspecified error has occurred.","presentationHint":{"attributes":["readOnly","failedEvaluation"]},"evaluateName":"result","variablesReference":0}]}}
Other Extensions

No response

Additional Information

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Download and run VSCodeWatchWindowTest.zip using the tasks.json build task and launch.json configuration. Start at main.cpp line 19 and compare the Watch/Locals results with the compiler settings used by build.bat, especially the permissive- flag. Done means result evaluates to its contents in the Watch Window instead of reporting an undefined identifier.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, vscode
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.