<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 --- - num_get::do_get incorrect digit grouping check"
   href="https://llvm.org/bugs/show_bug.cgi?id=28704">28704</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>num_get::do_get incorrect digit grouping check
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </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>llvm-bugs@daryl.haresign.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, mclow.lists@gmail.com
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>For a locale which specifies digit grouping, num_get::do_get will enforce
that the number read in contains the grouping character at the correct
locations.  It does this even if the number read in didn't have any grouping
characters present.

This is shown best with a code example:

  #include <iostream>
  #include <sstream>

  int main()
  {
    std::locale::global(std::locale("en_US.UTF-8"));
    std::istringstream iss("1024");
    int a = 0;
    iss >> a;
    std::cout << a << ", " << iss.fail() << std::endl;
  }

With libc++ this prints:

  1024, 1

With libstdc++ this prints:

  1024, 0

<a href="http://coliru.stacked-crooked.com/a/9283df64c2bd5142">http://coliru.stacked-crooked.com/a/9283df64c2bd5142</a>

The standard says:

<span class="quote">> Digit grouping is checked. That is, the positions of discarded separators is
> examined for consistency with
> use_facet<numpunct<charT> >(loc).grouping(). If they are not consistent then
> ios_base::failbit is assigned to err.</span >

<a href="http://eel.is/c++draft/facet.num.get.virtuals#4">http://eel.is/c++draft/facet.num.get.virtuals#4</a>

Whilst the standard could be clearer, it seems one can take it to mean that as
there are no discarded characters, there is nothing to examine for consistency.

This is the approach that libstdc++ takes, as well as boost's lexical_cast:

<a href="https://svn.boost.org/trac/boost/ticket/5585">https://svn.boost.org/trac/boost/ticket/5585</a>

I think it's reasonable that libc++ changes its implementation to match.</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>