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



The information in this article applies to:

  • The Microsoft Foundation Classes (MFC), when used with:
    • Microsoft Visual C++, 32-bit Editions 6.0

This article was previously published under Q241854

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 that this is a bug in the Microsoft products that are 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.

Modification Type:MajorLast Reviewed:10/17/2003
Keywords:kbBug KB241854