Menu

#138 _Stl_atod crash in MSVC2005 with Smaller Type Check

open
nobody
5
2007-08-09
2007-08-09
No

num_get_float.cpp, line #522 and up

/* Round to 53 bits */
rest = value & (1<<10)-1;
value >>= 10;
#if !defined(__SC__)
guard = (uint32) value & 1;
#else //*TY 03/25/2000 -
guard = to_ulong(value & 1);
#endif

The line (526): guard = (uint32) value & 1;
Should read : guard = (uint32)( value & 1 );

Under MSVC2005, with Smaller Type Check compiler option on, the line might have a large value, and will execute the conversion to (uint32) before the bitwise-and &, meaning under cases where the dc is bigger than a uint32, it will assert.

Added study: This has the advantage of being numerically valid, as currently the compiler has to assume the uint32 value is getting plainly truncated. However, this has the disadvantage of doing a potential asm "load high 32 bits of value" followed by a "and to 0", while using a useless always-zero second register/memory variable. To make it execute in MSVC2005, I find this a small price to pay.

Discussion


Log in to post a comment.