From 5666471362384471242
X-Google-Thread: f78e5,9a15691824828cc,start
X-Google-Attributes: gidf78e5,public
X-Google-Language: ENGLISH,ASCII-7-bit
Path: g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!wn14feed!worldnet.att.net!207.14.113.41!news.alt.net!comp-std-cpp-robomod!not-for-mail
From: "=?iso-8859-1?q?Daniel_Kr=FCgler?=" <daniel.kruegler@googlemail.com>
Newsgroups: comp.std.c++
Subject: Defect Report [N2134]: New 27.6.1.2.2 changes make special extractions useless
Date: Sun,  1 Apr 2007 14:41:39 CST
Organization: http://groups.google.com
Lines: 88
Approved: Fergus Henderson <fjh@cs.mu.oz.au>, moderator of comp.std.c++
Message-ID: <1175361373.332663.19940@e65g2000hsc.googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
X-Trace: posting.google.com 1175361374 25392 127.0.0.1 (31 Mar 2007 17:16:14 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Sat, 31 Mar 2007 17:16:14 +0000 (UTC)
Return-Path: <devnull@stump.algebra.com>
X-Authentication-Warning: mulga.csse.unimelb.edu.au: fjh set sender to devnull@stump.algebra.com using -f
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
X-Original-To: std-c++@mailman.ucar.edu
Delivered-To: std-c++@mailman.ucar.edu
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3,gzip(gfe),gzip(gfe)
Complaints-To: groups-abuse@google.com
Injection-Info: e65g2000hsc.googlegroups.com; posting-host=85.179.163.176;
   posting-account=0YhmiQ0AAABRDjD_6coNmBVB3rgPlaOq
X-Virus-Scanned: amavisd-new at ucar.edu
X-Virus-Scanned: amavisd-new at csse.unimelb.edu.au
X-Virus-Scanned: amavisd-new at csse.unimelb.edu.au
Xref: g2news1.google.com comp.std.c++:8324

To the more drastic changes of 27.6.1.2.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 27.6.2.5.2, is a
deliberate
decision or an oversight.

Proposed resolution:

1) In 27.6.1.2.2/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)
  && (lval < numeric_limits<short>::min()
    || numeric_limits<short>::max() < lval))
      err = ios_base::failbit;
setstate(err);

to

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 27.6.1.2.2/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)
  && (lval < numeric_limits<int>::min()
    || numeric_limits<int>::max() < lval))
      err = ios_base::failbit;
setstate(err);

to

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) ---

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]



