Home Dashboard Directory Help
Search

MFC C++ fails to compile use of codecvt_utf8 in Debug Configuration by DrK273


Status: 

Closed
 as Fixed Help for as Fixed


2
0
Sign in
to vote
Type: Bug
ID: 683483
Opened: 8/9/2011 2:36:46 AM
Access Restriction: Public
Moderator Decision: Sent to Engineering Team for consideration
2
Workaround(s)
view
0
User(s) can reproduce this bug

Description

I wish to use codecvt_utf8 to write UTF-8 data to a std::wofstream file in a MFC C++ application. Compiles and works OK in the Release configuration. Fails to compile in Debug configuration.

Workaround is to delete the following lines always added by the MFC project Wizard. However, I do not wish to do this in my large MFC application.

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

It seems that the 'new' operator in std::codecvt_utf8 conflicts with the MFC 'DEBUG_NEW' operator.
Details
Sign in to post a comment.
Posted by Microsoft on 1/6/2012 at 4:39 PM
Hi,

Thanks for reporting this bug. We've fixed it, and the fix will be available in VC11.

According to the Standard, macroizing keywords when including Standard Library headers triggers undefined behavior, and VC11 will emit a hard #error when it detects this. However, macroizing "new" is unfortunately very common, so we've added special guards to all C++ Standard Library headers that will grant them immunity to macroized "new".

If you have any further questions, feel free to E-mail me at stl@microsoft.com .

Stephan T. Lavavej
Visual C++ Libraries Developer
Posted by DrK273 on 9/15/2011 at 8:15 AM
It is over 5 weeks since I submitted this report and nearly 3 weeks since I asked for an update. Please provide an update as to the status of this issue?

Have you confirmed the issue?

Do you intend to fix it in this release of Visual Studio (2010)?
Posted by DrK273 on 8/29/2011 at 3:46 AM
Is there any update please?
Posted by MS-Moderator10 [Feedback Moderator] on 8/9/2011 at 7:11 PM
Thank you for submitting feedback on Visual Studio 2010 and .NET Framework. Your issue has been routed to the appropriate VS development team for investigation. We will contact you if we require any additional information.
Posted by MS-Moderator01 on 8/9/2011 at 2:50 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.
Posted by yfital on 12/24/2012 at 12:57 AM
FYI, another work around is to just write

std::locale utf8(std::locale(), ::new std::codecvt_utf8<wchar_t>);

That will force the compiler to use the global new, instead of the locale new
Posted by DrK273 on 8/9/2011 at 2:40 AM
Workaround is to delete the following lines in the source file that are always added by the MFC project Wizard.

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

But this should not be required!