I was looking for calculation errors in an old C++ Win32 program compiled by VS Pro 2022.
The problem was found to be caused by the following code which always produced a result of zero:
double dMetalFrameR = 0.0;
if (m_dMetalDoorK)
double dMetalFrameR = m_dMetalDoorX / m_dMetalDoorK;
Once the redeclaration was removed, it worked correctly:
double dMetalFrameR = 0.0;
if (m_dMetalDoorK)
dMetalFrameR = m_dMetalDoorX / m_dMetalDoorK;
The redeclaration is obviously incorrect, but why is the result always zero?
I would have expected a compiler warning but correct calculation.