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

Last reviewed: July 22, 1997
Article ID: 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 <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


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 22, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.