https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80624
Bug ID: 80624 Summary: char_traits<char16_t>::eof() doesn't meet requirements Product: gcc Version: 8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: redi at gcc dot gnu.org Target Milestone: --- #include <string> using u16_traits = std::char_traits<char16_t>; constexpr u16_traits::char_type c = u'\uFFFF'; constexpr u16_traits::int_type e = u16_traits::eof(); static_assert( u16_traits::eq_int_type(e, c) == false, "eof() is correct" ); [char.traits.require] says eof() return "a value e such that X::eq_int_type(e,X::to_int_type(c)) is false for all values c." Despite being a noncharacter, u'\uFFFF' is a valid code point, see http://www.unicode.org/faq/private_use.html#nonchar7 and http://www.unicode.org/faq/private_use.html#nonchar8 This means there's no way to tell if std::ostream<char16_t>::put(u'\uFFFF') is successful, because it returns to_int_type(u'\uFFFF') on success and returns eof() on failure, which compares equal. This might be fixable by making to_int_type(eof()) return u'\uFFFD' as suggested by the FAQ linked to above.