Possible bug with optimization.
#define UNICODE
#define _UNICODE
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
double test(long a, long b, int c, double d)
{
if (b + c > 1000)
return (-1111.11);
return (d * 2.0);
}
double test1(long a, long b, int c, double d)
{
return d;
}
double test2(long a, long b, int c, double d)
{
if (b > 1000)
return (-1111.11);
return d;
}
double test3(long a, long b, int c, double d)
{
if (c > 1000)
return (-1111.11);
return d;
}
int __cdecl WinMainCRTStartup(void)
{
double dbl = 1.0;
WCHAR str[200];
wsprintf(str, _T("test1: %f=%f"), dbl, test1(1,2,3,dbl));
OutputDebugString(str);
wsprintf(str, _T("test2: %f=%f"), dbl, test2(1,2,3,dbl));
OutputDebugString(str);
wsprintf(str, _T("test2: %f=%f"), dbl, test3(1,2,3,dbl));
OutputDebugString(str);
return 0;
}
Output where test3 fail:ODS: test1: 1.000000=1.000000
ODS: test2: 1.000000=1.000000
ODS: test2: 1.000000=0.000000
EDIT:test3:
[00011090] E92D4030 stmdb sp!, {r4, r5, lr}
[00011094] E1A04003 mov r4, r3 <- ? overwrite register
[00011098] E1A05004 mov r5, r4 <- ?
[0001109C] E3520FFA cmp r2, #3E8
[000110A0] DA000004 ble 000110B8
[000110A4] E59F0004 ldr r0, [pc, #+4] ; PC+8+4 = 000110B0
[000110A8] E59F1004 ldr r1, [pc, #+4] ; PC+8+4 = 000110B4
[000110AC] EA000003 b 000110C0
[000110B0] A3D70A3D bicges r0, r7, #3D000
[000110B4] C0915C70 addgts r5, r1, r0, ror ip
@294:
[000110B8] E1A00004 mov r0, r4
[000110BC] E1A01005 mov r1, r5
@293:
[000110C0] E8BD8030 ldmia sp!, {r4, r5, pc}