BUG: ASSERT in Strex.cpp, Line 690 with CString::Format

ID: Q241854


The information in this article applies to:
  • The Microsoft Foundation Classes (MFC), included with:
    • Microsoft Visual C++, 32-bit Editions, version 6.0, used with:
      • Microsoft Visual Studio versions 6.0, 6.0 SP3


SYMPTOMS

Using CString::Format, gives an assertion in Strex.cpp, line 690. This problem occurs when the %+f format string is used. Previous versions of Visual C++ do not give this assertion. Also, only the Service Pack 3 (SP3) debug version of MFC gives this assertion; the SP3 retail version does not give the assertion.


CAUSE

This problem is due to a bug in the parsing of the format string in the MFC code.


RESOLUTION

The following are three workarounds:

  • Use code similar to the following:
    
     	CString myStr;
    #ifdef _DEBUG
    	myStr.GetBufferSetLength(9);
    	myStr.ReleaseBuffer();
    #endif
    	myStr.Format("%+f", 1.0); 


  • Use the format string %+.6f instead of %+f.


  • Build the project in release configurations because the assertion does not occur with a release build.



STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.


MORE INFORMATION

Steps to Reproduce Behavior

  1. Create a new MFC AppWizard project.


  2. In the InitInstance function, add the following two lines at the top of the function:
    
    CString str;
    str.Format("%+f", 1.0); 


  3. Build the project and ensure that a debug build configuration is specified.


You get an assert in Strex.cpp, line 690 when the program is run.

Additional query words: SP3only parse format string floating point

Keywords : kbMFC kbVC600 kbVS600sp3bug kbDSupport kbGrpMFCATL
Version : winnt:6.0
Platform : winnt
Issue type : kbbug


Last Reviewed: October 8, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.