4 ms·
It might be an hypercorrection. memcpy is a safe way to do type punning, but no punning is necessary here as the pointee was originally a double so the cast bac
by gpderetta 4y ago
It might be an hypercorrection. memcpy is a safe way to do type punning, but no punning is necessary here as the pointee was originally a double so the cast back and dereference should be perfectly safe.
edit s/pointer/pointee
- cochne 4y agoYep, this works just fine: int compare(const void *a, const void *b) { return *(double*)a - *(double*)b; }