<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 4063: Freestanding std::char_traits&lt;char&gt;::eof depends on non-freestanding EOF</title>
<meta property="og:title" content="Issue 4063: Freestanding std::char_traits&lt;char&gt;::eof depends on non-freestanding EOF">
<meta property="og:description" content="C++ library issue. Status: New">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue4063.html">
<meta property="og:type" content="website">
<meta property="og:image" content="http://cplusplus.github.io/LWG/images/cpp_logo.png">
<meta property="og:image:alt" content="C++ logo">
<style>
  p {text-align:justify}
  li {text-align:justify}
  pre code.backtick::before { content: "`" }
  pre code.backtick::after { content: "`" }
  blockquote.note
  {
    background-color:#E0E0E0;
    padding-left: 15px;
    padding-right: 15px;
    padding-top: 1px;
    padding-bottom: 1px;
  }
  ins {background-color:#A0FFA0}
  del {background-color:#FFA0A0}
  table.issues-index { border: 1px solid; border-collapse: collapse; }
  table.issues-index th { text-align: center; padding: 4px; border: 1px solid; }
  table.issues-index td { padding: 4px; border: 1px solid; }
  table.issues-index td:nth-child(1) { text-align: right; }
  table.issues-index td:nth-child(2) { text-align: left; }
  table.issues-index td:nth-child(3) { text-align: left; }
  table.issues-index td:nth-child(4) { text-align: left; }
  table.issues-index td:nth-child(5) { text-align: center; }
  table.issues-index td:nth-child(6) { text-align: center; }
  table.issues-index td:nth-child(7) { text-align: left; }
  table.issues-index td:nth-child(5) span.no-pr { color: red; }
  @media (prefers-color-scheme: dark) {
     html {
        color: #ddd;
        background-color: black;
     }
     ins {
        background-color: #225522
     }
     del {
        background-color: #662222
     }
     a {
        color: #6af
     }
     a:visited {
        color: #6af
     }
     blockquote.note
     {
        background-color: rgba(255, 255, 255, .10)
     }
  }
</style>
</head>
<body>
<hr>
<p><em>This page is a snapshot from the LWG issues list, see the <a href="lwg-active.html">Library Active Issues List</a> for more information and the meaning of <a href="lwg-active.html#New">New</a> status.</em></p>
<h3 id="4063"><a href="lwg-active.html#4063">4063</a>. Freestanding <code>std::char_traits&lt;char&gt;::eof</code> depends on non-freestanding <code>EOF</code></h3>
<p><b>Section:</b> 27.2.4.2 <a href="https://wg21.link/char.traits.specializations.char">[char.traits.specializations.char]</a> <b>Status:</b> <a href="lwg-active.html#New">New</a>
 <b>Submitter:</b> Jiang An <b>Opened:</b> 2024-04-03 <b>Last modified:</b> 2024-05-08</p>
<p><b>Priority: </b>2
</p>
<p><b>View all other</b> <a href="lwg-index.html#char.traits.specializations.char">issues</a> in [char.traits.specializations.char].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#New">New</a> status.</p>
<p><b>Discussion:</b></p>
<p>
Currently <code>EOF</code> is not yet freestanding, because it's only specified to be provided in 
<code>&lt;stdio.h&gt;</code> in C, or together with <code>&lt;cstdio&gt;</code> in C++.
<p/>
However, <code>std::char_traits&lt;char&gt;::eof</code> (required to be freestanding since C++26 by 
<a href="https://wg21.link/P2338R4" title=" Freestanding Library: Character primitives and the C library">P2338R4</a>) is required to return the value of <code>EOF</code>. It's unclear what is 
expected to be done in a freestanding implementation.
<p/>
Related to <a href="https://github.com/llvm/llvm-project/issues/85158">LLVM issue #85158</a>.
</p>

<p><i>[2024-05-08; Reflector poll]</i></p>

<p>
Set priority to 2 after reflector poll.
</p>
<p>
"The <code class='backtick'>eof</code>, <code class='backtick'>not_eof</code>, <code class='backtick'>to_int_type</code> and <code class='backtick'>to_char_type</code> members of <code class='backtick'>char_traits</code>
are only needed by iostreams, so I see no reason for them to be freestanding.
In libstdc++ <code class='backtick'>eof</code> and <code class='backtick'>not_eof</code> 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."
</p>
<p>
"<code class='backtick'>int_type</code>/<code class='backtick'>char_type</code>/<code class='backtick'>eof</code> is kind of poor-man (or C)'s
<code>optional&lt;char_type&gt;</code>. Inclined to support it in freestanding
on that basis, even if the only standard component that uses it is iostreams."
</p>
<p>
"No implementer is confused about the value of <code class='backtick'>eof()</code>/<code class='backtick'>EOF</code>.
Having the value specified in the non-freestanding part of the standard
should be good enough."
</p>
<p>
"Prefer to make EOF freestanding, but don't feel strongly about it.
The important thing is keeping <code class='backtick'>string_view</code> working."
</p>



<p id="res-4063"><b>Proposed resolution:</b></p>





</body>
</html>
