Source-Level Debugging of Compiler-Optimised Code: Ill-Posed, but Not Impossible, https://dl.acm.org/doi/10.1145/3689492.3690047. There's almost no research in this area so it's good to see someone thinking about some of the challenges. I'd like to have seen a discussion of undefined behavior, specifically, since there's a paradox where C programmers are most likely to use debuggers exactly in cases where UB is present, which poses fundamental challenges to source-level debugging.
@pervognsen There was a talk by the visual studio team at cppcon about their cool new thing in that area: compile everything twice, optimized and unoptimized and switch to the unoptimized version when a breakpoint is hit.

@foonathan
Sounds like sth with a high potential to make bugs disappear when you're watching them with a debugger.

Also, does that mean they do JIT-like safepoints - points in the optimized programs where all variables exist in well-defined locations?
@pervognsen

@wolf480pl @foonathan Reading between the lines of their announcement blog post at https://devblogs.microsoft.com/cppblog/cpp-dynamic-debugging-full-debuggability-for-optimized-builds/, I think it's done at function entry, so it's not like traditional deoptimization where it can happen at the finer granularity on control back-edges inside loops or whatever.
C++ Dynamic Debugging: Full Debuggability for Optimized Builds - C++ Team Blog

Over the past 5 years, we’ve had many incredible opportunities to engage with game developers. From AAA studios to indie developers, the passion for slashing iteration times is significant. Amidst all the fantastic feedback we’ve received for Visual Studio, one sentiment has rung loud and clear: a desire to debug optimized C++ code without sacrificing […]

C++ Team Blog