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

ID: Q116444

1.00 1.50 WINDOWS kbprg kbbuglist

The information in this article applies to:

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 <stdio.h>
   #include <stdlib.h>
   #include <string.h>

   #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

Last Reviewed: July 23, 1997