From -3003680785117466084
X-Google-Thread: f78e5,5765784582f38606
X-Google-Attributes: gidf78e5,public
X-Google-Language: ENGLISH,ASCII
Path: g2news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!pd7cy3no!shaw.ca!news.alt.net!comp-std-cpp-robomod!not-for-mail
From: "Greg Herlihy" <greghe@pacbell.net>
Newsgroups: comp.std.c++
Subject: Re: codecvt::length
Date: Wed, 27 Sep 2006 08:49:15 CST
Organization: http://groups.google.com
Lines: 42
Approved: Fergus Henderson <fjh@cs.mu.oz.au>, moderator of comp.std.c++
Message-ID: <1159348327.426135.120060@h48g2000cwc.googlegroups.com>
References: <1159225259.934455.72830@i42g2000cwa.googlegroups.com>
   <1159267072.681597.305970@m7g2000cwm.googlegroups.com>
   <1159301894.038683.204860@e3g2000cwe.googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: posting.google.com 1159348332 2721 127.0.0.1 (27 Sep 2006 09:12:12 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Wed, 27 Sep 2006 09:12:12 +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 (Macintosh; U; Intel Mac OS X; en) AppleWebKit/418.8 (KHTML, like Gecko) Safari/419.3,gzip(gfe),gzip(gfe)
Complaints-To: groups-abuse@google.com
Injection-Info: h48g2000cwc.googlegroups.com; posting-host=71.141.243.2;
   posting-account=JdllFQ0AAAC-QghphnHMZz5q0GHnzGUJ
X-Virus-Scanned: amavisd-new at ucar.edu
X-Virus-Scanned: amavisd-new at csse.unimelb.edu.au
X-MIME-Autoconverted: from quoted-printable to 8bit by mulga.csse.unimelb.edu.au id k8R9EFa3011534
X-Virus-Scanned: amavisd-new at csse.unimelb.edu.au
Xref: g2news2.google.com comp.std.c++:3907


abadura wrote:
>    So OK. From 9a (and constraints on codecvt::do_in) it is quite clear
> that "max" must such a value that "to+max" and "(to+max)-to" are valid
> and well-defined. And since "(to+max)-to"="max" but is of type
> "ptrdiff_t" (because it is arithemtic on pointers). So "max" can be
> represented by an object of "ptrdiff_t" type.
>    Now we now that the result comes from "max" (so can be stored in
> "ptrdiff_t") or from "from_end-from" (again "ptrdiff_t") or is less
> then "from_end-from" (because of the coding properties (again can be
> sotred in "ptrdiff_t").
>    But the return value is of type "int" not "ptrdiff_t". And note that
> preconditions do not mention that "from_end-from" must fit into "int".
>
>    So now suppose that "int" has 32 bits, "ptrdiff_t" has 64 bits (must
> be signed) and "size_t" has also 64 bits (i suppose it must be
> unsigned). As for my knowledge this is possible for an implementation.
> If you think that not then please point parts of standard that forbid
> this (I couldn't find them).
>    Now it is possible to give such (valid) values for as arguments that
> the specified result will not fit into "int". What then?

�22.2.1.4.2/13 prevents codecvt::length() from ever getting itself
into such a bind: that is, the state of having advanced its current
location so far from its starting location, that the distance between
the two locations exceeds the maximum value that its return type can
represent.

Instead we can deduce that as soon as the distance between
codecvt::length()'s starting and current location becomes equal to the
maximum value that length() can return for its result - the method
stops advancing and returns MAX_INT as the result. 

Greg


---
[ 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                      ]



