Bizarre code of the day from Stackoverflow

Code:

unsigned char* _pos = …;

double result;

*((int*)&result) = *((int*)_pos);

Let’s see: taking int size bytes and moving them to a double.

One can only view with amazement and contemplate the horror a maintainer will experience. Oh BTW, it does cause a crash under some levels of compiler optimization.

About zaph

Long term Mac/iOS & Cocoa developer.
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply