Annex C (informative) Compatibility [diff]

C.2 C++ and ISO C++ 2017 [diff.cpp17]

C.2.14 [input.output]: input/output library [diff.cpp17.input.output]

Affected subclause: [istream.extractors]
Change: Character array extraction only takes array types.

Rationale: Increase safety via preventing buffer overflow at compile time.

Effect on original feature: Valid C++ 2017 code may fail to compile in this revision of C++: auto p = new char[100]; char q[100]; std::cin >> std::setw(20) >> p; // ill-formed; previously well-formed std::cin >> std::setw(20) >> q; // OK
Affected subclause: [ostream.inserters.character]
Change: Overload resolution for ostream inserters used with UTF-8 literals.

Rationale: Required for new features.

Effect on original feature: Valid C++ 2017 code that passes UTF-8 literals to basic_­ostream<char, ...>​::​operator<< or basic_­ostream<wchar_­t, ...>​::​operator<< is now ill-formed.
std::cout << u8"text"; // previously called operator<<(const char*) and printed a string; // now ill-formed std::cout << u8'X'; // previously called operator<<(char) and printed a character; // now ill-formed
Affected subclause: [ostream.inserters.character]
Change: Overload resolution for ostream inserters used with wchar_­t, char16_­t, or char32_­t types.

Rationale: Removal of surprising behavior.

Effect on original feature: Valid C++ 2017 code that passes wchar_­t, char16_­t, or char32_­t characters or strings to basic_­ostream<char, ...>​::​operator<< or that passes char16_­t or char32_­t characters or strings to basic_­ostream<wchar_­t, ...>​::​operator<< is now ill-formed.
std::cout << u"text"; // previously formatted the string as a pointer value; // now ill-formed std::cout << u'X'; // previously formatted the character as an integer value; // now ill-formed
Affected subclause: [fs.class.path]
Change: Return type of filesystem path format observer member functions.

Rationale: Required for new features.

Effect on original feature: Valid C++ 2017 code that depends on the u8string() and generic_­u8string() member functions of std​::​filesystem​::​path returning std​::​string is not valid in this revision of C++.
std::filesystem::path p; std::string s1 = p.u8string(); // ill-formed; previously well-formed std::string s2 = p.generic_u8string(); // ill-formed; previously well-formed