在将 VS6 项目移植到 VC++2012 环境时,我遇到了一种奇怪的行为......
假设我有以下
// double AreaIco = 75.0;
// double theApp.m_GlobalScale = 0.25;
double ToLong(double); // elsewhere defined
double result = ToLong(AreaIco * theApp.m_GlobalScale * theApp.m_GlobalScale);
我发现 ToLong 函数将“0”作为输入参数
如果我尝试引入临时变量,也会发生这种情况:
double temp1 = AreaIco * theApp.m_GlobalScale;
double temp2 = temp1 * theApp.m_GlobalScale;
AreaIcoInScala = ToLong(temp2);
temp1 和 temp2 都计算为 0 或非规范化值。
但是,尝试评估 QuickWatch 中的表达式会返回正确的值。
有没有人对这种行为有任何线索?我担心代码中存在一些古老的错误,从现在开始,VS6 中的 somethink 已经涵盖了这些错误......
无论如何,感谢任何人的支持。