unreachable code with 'maximize speed'

Started by JohnF, July 21, 2012, 11:36:21 AM

Previous topic - Next topic

JohnF

The following code is fine with optimized speed if "BM" is a string but will not do as a literal.


#include <stdio.h>

int main(void)
{
short bfType = 0x4D42;

if ((bfType == *(short *)"BM"))
{
printf("OK\n"); // unreachable code with 'maximize speed'
}
else
{
printf("Not OK\n");
}

return 0;
}


John

Pelle

Questionably code, at least. I will see what I can do...
/Pelle