Please consider the following code:
float float_value = x; // x is any valid float value
int int_value = 0;
size_t size = sizeof(int) < sizeof(float) ? sizeof(int) : sizeof(float);
memcpy(&int_value, &float_value, size);
As far as i know this could result in an trap representation. My questions:
- Is that true?
- If not, why?
- If not, is there another way avoiding a possible trap representation?