Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardC++inlining and the as-if ruleSingle-choice MCQ

The compiler inlines `f` into `g`, then proves via escape analysis that a heap allocation in `f` never escapes `g`. What does the standard actually permit here regarding the `new`/`delete` pair?

int g(int n) { int* p = new int(n); // does not escape int r = *p * 2; delete p; return r; }