A new[] that never leaves the function

point never escapes makePoint: it is not returned, not stored anywhere, not passed on, and the matching delete[] runs before the return. Compiled with -O2, do the allocation and deallocation calls survive into the generated code?

main.cpp
#include <cstdio>

int makePoint(int x, int y) {
    int* point = new int[2]{x, y};
    int sum = point[0] + point[1];
    delete[] point;
    return sum;
}

24 of 44 in Compilers