2 ms·
You're right. Type punning via pointer cast, e.g. int i = ... float f = *(float*) &i; is not fine (violates strict aliasing). Type punning via union, e.g.
by Kristine1975 11y ago
You're right. Type punning via pointer cast, e.g.
int i = ...
float f = *(float*) &i;
is not fine (violates strict aliasing). Type punning via union, e.g.
union { int i; float f; } u;
u.i = ...
float f = u.f;
is, though (but only in C).
Just use memcpy :-)