Microsoft KB Archive/116444

From BetaArchive Wiki

BUG: _strtod Fails with Buffer >100 Bytes with /AL and /FPa

Q116444

1.00 1.50 WINDOWS kbprg kbbuglist ---------------------------------------------------------------------- The information in this article applies to: - The C Run-time (CRT), included with: - Microsoft Visual C++ for Windows, versions 1.0 and 1.5 ---------------------------------------------------------------------- SYMPTOMS ======== When a source module that makes a call to _strtod() is compiled using /FPa (alternate math library) and /AL (large memory model), and then is run, the _strtod() call fails if the size of the string sent as the first parameter is greater than 100 bytes. CAUSE ===== There is call to strlen() in _strtod(), which makes a floating-point call. The result from the call is not correct. STATUS ====== Microsoft has confirmed this to be a bug with Visual C++ for Windows, versions 1.0 and 1.5. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available. This is not a problem with the 32-bit compilers. MORE INFORMATION ================ /* Compile options needed: /AL /FPa */ #include #include #include #define BUFFER_SIZE 0x4000 int main (void) { char *pBuffer = new char [BUFFER_SIZE]; char *pBuf, *pBuf2, *pNext = "0"; unsigned uCount; for (uCount = 1, pBuf = pBuffer; uCount < BUFFER_SIZE; ++uCount, ++pBuf) { strcpy (pBuf, pNext); putchar (*pNext); // Fill the buffer with ","s to illustrate the fact that // strtod does not have to parse a long number; it only has to // parse a "0" and ignore the ","s, but it still fails. pNext = ","; strtod (pBuffer, &pBuf2); if (pBuf2 == pBuffer) { printf ("\nStrtod failed at character %u\n", uCount); delete pBuffer; return 1; } } printf ("\n Strtod copied %u chars successfully\n", uCount); delete pBuffer; return 0; } Additional reference words: 1.00 1.50 KBCategory: kbprg kbbuglist KBSubcategory: CRTIss

Keywords : kb16bitonly
Issue type : kbbug
Technology : kbVCsearch kbAudDeveloper kbCRT


Last Reviewed: May 5, 2001
© 2001 Microsoft Corporation. All rights reserved. Terms of Use.