Search

This instantiation of std::codecvt template does not meet standard requirements for std::codecvt::out by Seth__

Closed
as Fixed Help for as Fixed

1
0
Sign in
to vote
Type: Bug
ID: 705152
Opened: 11/17/2011 10:17:51 AM
Access Restriction: Public
Moderator Decision: Sent to Engineering Team for consideration
0
Workaround(s)
0
User(s) can reproduce this bug
I'm calling the member function 'out' on a particular instantiation of the codecvt template. For this instantiation the behavior of this member function does not match the standard's specifications. The standard states that if 'out' returns the value 'noconv' then the internal character type and the external character type of the codecvt are the same (C++11 ยง 22.4.1.4.2 p2). I am receiving this return value but the internal and external character types for my codecvt instantiation are not the same.


Here's a snippet of the code I'm using that demonstrates the bug:

        typedef char32_t CharT;
        typedef char_traits<CharT>::state_type StateT;
        typedef codecvt<CharT,char,StateT> CodecvtT;

        std::locale l;
        if (has_facet<CodecvtT>(l))
        {
            CodecvtT const &a_codecvt = use_facet<CodecvtT>(l);
            StateT state = StateT();
            CharT A[] = {'H'};
            CharT const *a;
            char B[4] = {};
            char *b;
            auto result = a_codecvt.out(state,A,A+1,a,B,B+1,b);

            if (CodecvtT::noconv == result)
            {
                assert(typeid(CharT)==typeid(char));
            }
        }


Details (expand)

Visual Studio/Team Foundation Server/.NET Framework Tooling version

Visual Studio 2010 SP1

Steps to reproduce

insert code snippet into main function of a program with appropriate #includes

build and run program

Also build and run the program with the CharT typedef set to other types, double, int, wchar_t, char.

Product Language

English

Operating System

Windows 7

Operating System Language

English

Actual results

The assertion that ensures the standard's requirement is followed fails.

The same error occurs when the CharT is double or short.

If CharT is set to wchar_t then the result does not equal 'noconv' so the assertion is not checked. If CharT is set to char then the result does equal 'noconv' but the assertion succeeds because CharT and char are the same type.

Expected results

With CharT set to char32_t the expression 'CodecvtT::noconv == result' should be false because char32_t and char are not the same type, so that the assertion is never checked.

With CharT set to double or short result should also not compare equal to noconv.

With CharT set to wchar_t and char the expected results match the actual results.
File Attachments
0 attachments
Sign in to post a comment.
Posted by Seth__ on 2/27/2012 at 5:16 PM
As of the VS11 DP I can't see that the behavior of this code has changed at all.
Posted by Microsoft on 1/6/2012 at 5:30 PM
Hi,

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

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 MS-Moderator10 [Feedback Moderator] on 11/17/2011 at 10:07 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 11/17/2011 at 6:25 PM
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.