Type punning through memcpy

Contrast this with the reinterpret_cast version of the same bit reinterpretation. What does the compiler make of it at -O2, and does it cost a runtime memory copy?

main.cpp
#include <cstring>

float bitsToFloat(int bits) {
    float f;
    std::memcpy(&f, &bits, sizeof(f));
    return f;
}

3 of 44 in Compilers