https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79980
--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> --- Author: redi Date: Thu Mar 16 15:27:51 2017 New Revision: 246200 URL: https://gcc.gnu.org/viewcvs?rev=246200&root=gcc&view=rev Log: PR libstdc++/79980 fix BOM detection, maxcode checks, UCS2 handling PR libstdc++/79980 * include/bits/locale_conv.h (__do_str_codecvt): Set __count on error path. * src/c++11/codecvt.cc (operator&=, operator|=, operator~): Overloads for manipulating codecvt_mode values. (read_utf16_bom): Compare input to BOM constants instead of integral constants that depend on endianness. Take mode parameter by reference and adjust it, to distinguish between no BOM present and UTF-16BE BOM present. (ucs4_in, ucs2_span, ucs4_span): Adjust calls to read_utf16_bom. (surrogates): New enumeration type. (utf16_in, utf16_out): Add surrogates parameter to choose between UTF-16 and UCS2 behaviour. (utf16_span, ucs2_span): Use std::min not std::max. (ucs2_out): Use std::min not std::max. Disallow surrogate pairs. (ucs2_in): Likewise. Adjust calls to read_utf16_bom. * testsuite/22_locale/codecvt/codecvt_utf16/79980.cc: New test. * testsuite/22_locale/codecvt/codecvt_utf8/79980.cc: New test. Added: trunk/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_utf16/79980.cc trunk/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_utf8/79980.cc Modified: trunk/libstdc++-v3/ChangeLog trunk/libstdc++-v3/include/bits/locale_conv.h trunk/libstdc++-v3/src/c++11/codecvt.cc