Title
Freestanding std::char_traits<char>::eof depends on non-freestanding EOF
Status
new
Section
[char.traits.specializations.char]
Submitter
Jiang An

Created on 2024-04-03.00:00:00 last changed 6 months ago

Messages

Date: 2024-05-15.00:00:00

[ 2024-05-08; Reflector poll ]

Set priority to 2 after reflector poll.

"The `eof`, `not_eof`, `to_int_type` and `to_char_type` members of `char_traits` are only needed by iostreams, so I see no reason for them to be freestanding. In libstdc++ `eof` and `not_eof` depend on hosted, so are not freestanding. Now that we can have partially freestanding classes in the library, that seems like the right solution here."

"`int_type`/`char_type`/`eof` is kind of poor-man (or C)'s optional<char_type>. Inclined to support it in freestanding on that basis, even if the only standard component that uses it is iostreams."

"No implementer is confused about the value of `eof()`/`EOF`. Having the value specified in the non-freestanding part of the standard should be good enough."

"Prefer to make EOF freestanding, but don't feel strongly about it. The important thing is keeping `string_view` working."

Date: 2024-04-03.00:00:00

Currently EOF is not yet freestanding, because it's only specified to be provided in <stdio.h> in C, or together with <cstdio> in C++.

However, std::char_traits<char>::eof (required to be freestanding since C++26 by P2338R4) is required to return the value of EOF. It's unclear what is expected to be done in a freestanding implementation.

Related to LLVM issue #85158.

History
Date User Action Args
2024-05-08 10:34:32adminsetmessages: + msg14118
2024-04-03 00:00:00admincreate