Microsoft KB Archive/241854

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

Article ID: 241854

Article Last Modified on 11/21/2006

-

APPLIES TO


 * Microsoft Foundation Class Library 4.2, when used with:
 * Microsoft Visual C++ 6.0 Service Pack 5

-



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; myStr.GetBufferSetLength(9); myStr.ReleaseBuffer; 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.
 * 1) ifdef _DEBUG
 * 1) endif



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.



Steps to Reproduce Behavior
 Create a new MFC AppWizard project.</li>  In the InitInstance function, add the following two lines at the top of the function: CString str; str.Format("%+f", 1.0); </li> Build the project and ensure that a debug build configuration is specified.</li></ol>

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

Additional query words: SP3only parse format string floating point

Keywords: kbbug KB241854

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.