The following C code shows different results when build in debug or release mode with Xcode 26.0.1.
#include <stdio.h>
static void print_fval(int16_t *src)
{
float fval = (float)((((int32_t)*src) << 16) - (1 << 31));
printf("fval: %f\n", fval);
}
int main(int argc, const char * argv[])
{
int16_t i16[1] = { 0 };
print_fval(i16);
return EXIT_SUCCESS;
}
In debug mode the output is: fval: -2147483648.000000. In release mode the output is: fval: 2147483648.00000. The 1 << 31 might be questionable but I would expect the same outcome in debug or release mode. The difference is in compiling with optimizations or not, compiler option -O0 vs any other optimization option. Would this be considered a compiler/optimizer bug? Older versions of Xcode (15.4 and earlier) do not have this problem.