661. New 27.6.1.2.2 changes make special extractions useless

Section: 31.7.5.3.2 [istream.formatted.arithmetic] Status: CD1 Submitter: Daniel Krügler Opened: 2007-04-01 Last modified: 2016-01-28

Priority: Not Prioritized

View all other issues in [istream.formatted.arithmetic].

View all issues with CD1 status.

Discussion:

To the more drastic changes of 31.7.5.3.2 [istream.formatted.arithmetic] in the current draft N2134 belong the explicit description of the extraction of the types short and int in terms of as-if code fragments.

  1. The corresponding as-if extractions in paragraph 2 and 3 will never result in a change of the operator>> argument val, because the contents of the local variable lval is in no case written into val. Furtheron both fragments need a currently missing parentheses in the beginning of the if-statement to be valid C++.
  2. I would like to ask whether the omission of a similar explicit extraction of unsigned short and unsigned int in terms of long - compared to their corresponding new insertions, as described in 31.7.6.3.2 [ostream.inserters.arithmetic], is a deliberate decision or an oversight.

Proposed resolution:

  1. In 31.7.5.3.2 [istream.formatted.arithmetic]/2 change the current as-if code fragment

    typedef num_get<charT,istreambuf_iterator<charT,traits> > numget;
    iostate err = 0;
    long lval;
    use_facet<numget>(loc).get(*this, 0, *this, err, lval );
    if (err == 0) {
      && if (lval < numeric_limits<short>::min() || numeric_limits<short>::max() < lval))
          err = ios_base::failbit;
      else
        val = static_cast<short>(lval);
    }
    setstate(err);
    

    Similarily in 31.7.5.3.2 [istream.formatted.arithmetic]/3 change the current as-if fragment

    typedef num_get<charT,istreambuf_iterator<charT,traits> > numget;
    iostate err = 0;
    long lval;
    use_facet<numget>(loc).get(*this, 0, *this, err, lval );
    if (err == 0) {
      && if (lval < numeric_limits<int>::min() || numeric_limits<int>::max() < lval))
          err = ios_base::failbit;
      else
        val = static_cast<int>(lval);
    }
    setstate(err);
    
  2. ---

[ Kona (2007): Note to the editor: the name lval in the call to use_facet is incorrectly italicized in the code fragments corresponding to operator>>(short &) and operator >>(int &). Also, val -- which appears twice on the line with the static_cast in the proposed resolution -- should be italicized. Also, in response to part two of the issue: this is deliberate. ]