<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW " title="NEW --- - std::char_traits&lt;char16_t&gt;::eof() returns valid code unit" href="https://urldefense.proofpoint.com/v2/url?u=https-3A__llvm.org_bugs_show-5Fbug.cgi-3Fid-3D24342&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=pF93YEPyB-J_PERP4DUZOJDzFVX5ZQ57vQk33wu0vio&m=tajEgRSXaFZYv2dPoXZ5k2sijdreTFFFmGK007kdt2Y&s=KuQyNbrs0HZHEGfldpC35sbYTflN0UzWx1t3yRmygR4&e=">24342</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>std::char_traits<char16_t>::eof() returns valid code unit
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libc++
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>3.6
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Macintosh
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>All Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>david_work@me.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu, mclow.lists@gmail.com
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>[char.traits.specializations.char16_t] ยง21.2.3.2/3 says,

"The member eof() shall return an implementation-defined constant that cannot
appear as a valid UTF-16 code unit."

In libc++ it returns 0xDFFF, which is a valid second half of a surrogate pair.
Surrogate pairs are only needed outside the basic multilingual plane, so it
won't often be seen, but characters like U+123FF are valid and encoded by
0xDFFF.

On the other hand, U+FFFF is a "noncharacter," "intended for process-internal
uses" similarly to the byte order mark (which happens to be the preceding code
point U+FFFE). (<a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__unicode.org_charts_PDF_UFFF0.pdf&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=pF93YEPyB-J_PERP4DUZOJDzFVX5ZQ57vQk33wu0vio&m=tajEgRSXaFZYv2dPoXZ5k2sijdreTFFFmGK007kdt2Y&s=-TNs9LrIxBuXhlcH18XWXvsg6OHuTFRSdL4LNaaYzbw&e=">http://unicode.org/charts/PDF/UFFF0.pdf</a>) U+FFFF is used by most
other environments, it is the value under libstdc++, and it coincides with WEOF
when wchar_t is UTF-16.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>