[diff.cpp17.input.output]

# Annex C (informative) Compatibility [[diff]](./#diff)

## C.3 C++ and ISO C++ 2017 [[diff.cpp17]](diff.cpp17#input.output)

### C.3.14 [[input.output]](input.output "31 Input/output library"): input/output library [diff.cpp17.input.output]

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1427)

**Affected subclause:** [[istream.extractors]](istream.extractors)  


**Change:** Character array extraction only takes array types[.](#1.sentence-1)

  


**Rationale:** Increase safety via preventing buffer overflow at compile time[.](#1.sentence-2)

  


**Effect on original feature:** Valid C++ 2017 code may fail to compile in this revision of C++[.](#1.sentence-3)

[*Example [1](#example-1)*: 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 â *end example*]

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1443)

**Affected subclause:** [[ostream.inserters.character]](ostream.inserters.character)  


**Change:** Overload resolution for ostream inserters used with UTF-8 literals[.](#2.sentence-1)

  


**Rationale:** Required for new features[.](#2.sentence-2)

  


**Effect on original feature:** Valid C++ 2017 code that passes UTF-8 literals tobasic_ostream<char, ...>​::​operator<< orbasic_ostream<wchar_t, ...>​::​operator<< is now ill-formed[.](#2.sentence-3)

[*Example [2](#example-2)*: 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 â *end example*]

[3](#3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1462)

**Affected subclause:** [[ostream.inserters.character]](ostream.inserters.character)  


**Change:** Overload resolution for ostream inserters
used with wchar_t, char16_t, or char32_t types[.](#3.sentence-1)

  


**Rationale:** Removal of surprising behavior[.](#3.sentence-2)

  


**Effect on original feature:** Valid C++ 2017 code that passeswchar_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[.](#3.sentence-3)

[*Example [3](#example-3)*: 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 â *end example*]

[4](#4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L1483)

**Affected subclause:** [[fs.class.path]](fs.class.path)  


**Change:** Return type of filesystem path format observer member functions[.](#4.sentence-1)

  


**Rationale:** Required for new features[.](#4.sentence-2)

  


**Effect on original feature:** Valid C++ 2017 code that depends on the u8string() andgeneric_u8string() member functions of std​::​filesystem​::​path returning std​::​string is not valid in this revision of C++[.](#4.sentence-3)

[*Example [4](#example-4)*: 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 â *end example*]
