I have C++ native code that has been working for years across all versions of Visual Studio, from 2008 to 2022.
But I now observe a malfunction with the 2022 compiler, with the following symptoms:
- a call of a specific function is not performed* as should (causing abnormal execution);
- the debugger does not honor a breakpoint at the calling line nor inside the function;
- if I change the Inline Function Expansion mode from Default to Disabled (
/Ob0
or/Ob1
), things work normally; - if I precede the call with a dummy statement (
puts("")
), things work normally (!).
So it seems that the problem is related to function inlining. I have no better explanation than a compiler bug. I stress that the function is not declared inline, is not implemented in a header file, and the problem only manifests itself in a Release x64 build.
*When I say not performed, I mean that the call has no effect, though I am unsure if the function is actually inlined or not.
The code is complex, so before trying to supply minimal code, I am asking if similar problems have already been seen. Should I start to distrust and disable automatic inlining?