Do I understand you right that
for (int i=0; i<4; i++)
buf[i] = ((char*)&my_float)[i];
is not undefined behavior? But that for (int i=0; i<4; i++)
buf[i] = ((char*)(int32_t*)&my_float)[i];
is undefined?