- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Program compiled by Intel oneApi DPC++ compiler, integrated in Visual Studio IDE.
Visual Studio debugger does not show values of internal variables in lambda functions.
It is not critical error, but annoing...
My system is: Windows 20h2 + VisualStudio 16.11.5.+ Intel oneApi DPC++ (from w_BaseKit_p_2021.4.0.3421_offline)
Create DPCPPConsoleApplication, put following program:
//CppCon 2015: Arthur O'Dwyer “Lambdas from First Principles: A Whirlwind Tour of C++"” Puzzle #3
//https://youtu.be/WXeu4fj3zOs?t=1985
#include <iostream>
auto make_kitten(int c) {
static int a = 0;
return [=](int d) {
static int b = 0;
return (a++) + (b++) + c + d;// BREAKPOINT
};
}
int main()
{
auto k1 = make_kitten(1), k2 = make_kitten(2);
std::cout << "(21) k1(20)=" << k1(20) << " (33) k1(30)=" << k1(30) << std::endl;
std::cout << "(26) k2(20)=" << k2(20) << " (38) k2(30)=" << k2(30) << std::endl;
}
Make breakpoint at line "return (a++) + (b++) + c + d;// BREAKPOINT" and start program.
Reaching the breakpoint, the debugger shows correctly only the variable "с". Other variables "a", "b" and "d" are marked as "identifier "a" ("b", "d") is undefined."
But after switching compiler from Intel to Microsoft, all variables "a", "b", "c" and "d" are visible correctly in debugger. (VisualStudio menu - Project - Intel Compiler - Use Visual C++).
Then switch back to Intel compiler, rebuild solution, run program till the breakpoint - again three variables a,b and d are "undefined".
This example, shown by Arthur O'Dwyer, was chosen by me because each variable was created in a different way:
"a" - static outside the lambda
"b" - static inside the lambda
"c" - captured by value
"d" - the lambda's own argument
To get more info I put following diagnostics code before the breakpoint line "return (a++) + (b++) + c + d;// BREAKPOINT":
#if defined(__INTEL_LLVM_COMPILER)
std::cout << "Intel compiler=" << __INTEL_LLVM_COMPILER << std::endl;;
puts(__PRETTY_FUNCTION__); puts(__FUNCDNAME__);
#else
std::cout << "MS compiler=" << _MSC_FULL_VER << std::endl;;
puts(__FUNCSIG__); puts(__FUNCDNAME__);
#endif
Intel compiler prints diagnostics:
Intel compiler=20210400
auto make_kitten(int)::(anonymous class)::operator()(int) const
??R<lambda_0>@?0??make_kitten@@YA?A?<auto>@@H@Z@QEBA?A?2@H@Z
Visual C++ compiler prints:
MS compiler=192930136
auto __cdecl make_kitten::<lambda_be3af9280098e242fa98aeb8533f2dca>::operator ()(int) const
??R<lambda_be3af9280098e242fa98aeb8533f2dca>@@QEBA@H@Z
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Thanks for reaching out to us.
We are also able to reproduce the issue from our end.
We are looking into it. We will get back to you soon.
Thanks & Regards
Noorjahan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This issue has been escalated to our developers. We'll work on it internally and come back with update.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page