220 38519 <b5426ee6-f221-4342-b346-0963828a1ba9@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: joshua.r.marshall.1991@gmail.com
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Clarification of std::iterator_traits::distance_type
Date: Wed, 6 Jun 2018 06:46:49 -0700 (PDT)
Lines: 119
Approved: news@gmane.org
Message-ID: <b5426ee6-f221-4342-b346-0963828a1ba9@isocpp.org>
References: <5bceda10-ca60-4100-8fb3-16fcb8713552@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_47765_2130986432.1528292809923"
X-Trace: blaine.gmane.org 1528292685 15757 195.159.176.226 (6 Jun 2018 13:44:45 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Wed, 6 Jun 2018 13:44:45 +0000 (UTC)
Cc: joshua.r.marshall.1991@gmail.com
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCFIZIPVQEORBSWL37MAKGQERJEIX2Q@isocpp.org Wed Jun 06 15:44:41 2018
Return-path: <std-proposals+bncBCFIZIPVQEORBSWL37MAKGQERJEIX2Q@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-yw0-f197.google.com ([209.85.161.197])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCFIZIPVQEORBSWL37MAKGQERJEIX2Q@isocpp.org>)
	id 1fQYjx-0003yh-3O
	for gclcip-std-proposals@m.gmane.org; Wed, 06 Jun 2018 15:44:41 +0200
Original-Received: by mail-yw0-f197.google.com with SMTP id a203-v6sf4498127ywe.16
        for <gclcip-std-proposals@m.gmane.org>; Wed, 06 Jun 2018 06:46:52 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=date:from:to:cc:message-id:in-reply-to:references:subject
         :mime-version:x-original-sender:reply-to:precedence:mailing-list
         :list-id:list-post:list-help:list-archive:list-subscribe
         :list-unsubscribe;
        bh=9P3yKkxVwgTxKIcB4/edC2mrgEE6Ikn+8uTekeAgko4=;
        b=kNmMT+Bc+cCe7FNyjj/HSyVm5twYD/GDvnGWuOHDtzLt/jI7PzZP+QB1hQdzNScrOR
         cYyz/dD9FgVJnUqgv6T+8r1Xe/BQW3d4mS0wdvIEMCWlLatGGpJMspHw7Re9m36UFLbK
         /VLxj7pvEf43o5wCVibbEbflY2NPYXFuzOmKSxp67GBeCbH+AFuhoJcp7Lb+I++pem3p
         km1jz2WTRrZMkbgS+7gWatBbilcX9XctyFFanG+j5pgoEJEZmgHvs0UDglGZquhLOvgC
         0yptLsAPbbdxW1p1Evt/afUlbZxzbsB2QYtf08REQmcG9kg0AIXVaYsURbqwy3kwtSBQ
         7Quw==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=date:from:to:cc:message-id:in-reply-to:references:subject
         :mime-version:x-original-sender:reply-to:precedence:mailing-list
         :list-id:list-post:list-help:list-archive:list-subscribe
         :list-unsubscribe;
        bh=9P3yKkxVwgTxKIcB4/edC2mrgEE6Ikn+8uTekeAgko4=;
        b=sLt5bRfy1hFK8ryH8wG8ENGcX/TGqWgCq8GLM+rlvHD6XIBaisp7PBBYj69JO4+Pwl
         slzNJ9mSOcuSh/QDI4ogYFQK6IgxLXU7+I+5TWOEXUt3oPRHByx7H6M9jl0VwFtU6Pga
         d7RvTXX7eIxwOMtmLPRby/Cp7LV4KZeckDDQhgJLDibnHY4kUf0ntvYFnZIKL5DLD+3q
         VmPjls+0n7o+ayJIw/IA3tAAU/VwevXi2lV7443kNWtjKd7oW55dbVwgNZ4vW9jC18Ip
         FzzHo6NVJPvpVIgmvhe1nolAcKuOlWR+CoVJ1s+gHnTQAO0fBPpIw0Ln6enslZzq5h5b
         a1wQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:date:from:to:cc:message-id:in-reply-to
         :references:subject:mime-version:x-original-sender:reply-to
         :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post
         :list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=9P3yKkxVwgTxKIcB4/edC2mrgEE6Ikn+8uTekeAgko4=;
        b=bSP40UnrDkrQ2AIPBKU3OUpEw3vRPJ4BYI1IA7gRAcO/CrLKuY/dxiU1mO6E4sshNm
         9/DjqV8tqtOo3m045a71qFug1OfhWHyPGWtnh6g7bSbipIUJ+wYh1i0O5rXLwQV6FzJk
         uIdTX45pxXOZpw6fVO6rl5JbDQbskCO3B02H20g8t4l4fXpU30K9VHkHuCxzEPSAUllN
         3TtCsDGoGRC2RFmW3Cx4XCgc25JN+Rj4JX5Y04OC175O99Yn7FVZk1mP4dgoZgPFVhJu
         DAveWGHQseb+jZkq+IckhAtBWc86SCdokg9yi8BGZMconl+shxbCankULYyAjFDLwlYa
         eVFQ==
X-Gm-Message-State: APt69E0skNRSMDQChF8ITcnlY7E3eT0HefYaOyQIwNrZIVIsXLjuosql
	JQtv0uKiEPB1Le2QXe0M+PgBtw==
X-Google-Smtp-Source: ADUXVKINIkS7F3JRFF9778TT4/dVw29gZHg7lA7x7Vrge/s5VaCFVU3kXNlPeJMBsoKYIk3IH21UXQ==
X-Received: by 2002:a0d:db4f:: with SMTP id d76-v6mr879817ywe.228.1528292811948;
        Wed, 06 Jun 2018 06:46:51 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 2002:a25:44c:: with SMTP id 73-v6ls4125868ybe.11.gmail; Wed, 06
 Jun 2018 06:46:50 -0700 (PDT)
X-Received: by 2002:a25:aaa1:: with SMTP id t30-v6mr135258ybi.13.1528292810325;
        Wed, 06 Jun 2018 06:46:50 -0700 (PDT)
In-Reply-To: <5bceda10-ca60-4100-8fb3-16fcb8713552@isocpp.org>
X-Original-Sender: joshua.r.marshall.1991@gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Spam-Checked-In-Group: std-proposals@isocpp.org
X-Google-Group-Id: 399137483710
List-Post: <https://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <https://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <https://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>,
 <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:38519
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/38519>

------=_Part_47765_2130986432.1528292809923
Content-Type: multipart/alternative; 
	boundary="----=_Part_47766_841153955.1528292809923"

------=_Part_47766_841153955.1528292809923
Content-Type: text/plain; charset="UTF-8"

It looks like this will end up needed to be a change in the next standard, 
mainly about C++17 27.2.1 [iterator.requirements.general] paragraph 1.

On Wednesday, June 6, 2018 at 7:46:12 AM UTC-4, joshua.r.ma...@gmail.com 
wrote:
>
> There is a bug in glibc which seems to have arisen from ambiguity about 
> distance_type in std::iterator_traits.  It does not have defined required 
> operators or constructors, but is implied to behave line a signed integer.
>
> https://en.cppreference.com/w/cpp/iterator/iterator_traits
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86015
>
> This causes an issue with instrumentation of distance_type as everything 
> must be implicitly convertible to and from an int.  This is testable by 
> trying to build the following project:
> https://github.com/anadon/Sort-Comparisons-and-Performance-metrics
>
> The code of this original use case was from 1997 by David Musser and so 
> was permissible when the stdlib was being developed.
>
> I think the following clarifications are in order:
> std::iterator_traits::difference_type shall not necessarily be of any 
> particular built in datatype, but have the following properties:
> * All arithmetic operators available to signed integers must be defined
> * Implicit constructor from a signed integer type (std::ptrdiff_t) to 
> itself shall be available
> * An implicit conversion to any number type must not be present.
>
> This change, if found reasonable and valid, should be added backwards 
> through C++11 as a clarification.
>

-- 
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/b5426ee6-f221-4342-b346-0963828a1ba9%40isocpp.org.

------=_Part_47766_841153955.1528292809923
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>It looks like this will end up needed to be a change =
in the next standard, mainly about C++17 27.2.1 [iterator.requirements.gene=
ral] paragraph 1.</div><div><br></div>On Wednesday, June 6, 2018 at 7:46:12=
 AM UTC-4, joshua.r.ma...@gmail.com wrote:<blockquote class=3D"gmail_quote"=
 style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-=
left: 1ex;"><div dir=3D"ltr"><div>There is a bug in glibc which seems to ha=
ve arisen from ambiguity about distance_type in std::iterator_traits.=C2=A0=
 It does not have defined required operators or constructors, but is implie=
d to behave line a signed integer.<br></div><div><br></div><div><a href=3D"=
https://en.cppreference.com/w/cpp/iterator/iterator_traits" target=3D"_blan=
k" rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;https://www.google.com/=
url?q\x3dhttps%3A%2F%2Fen.cppreference.com%2Fw%2Fcpp%2Fiterator%2Fiterator_=
traits\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHKWOFdJjU1PvnpRNG8hkN993R_bQ=
&#39;;return true;" onclick=3D"this.href=3D&#39;https://www.google.com/url?=
q\x3dhttps%3A%2F%2Fen.cppreference.com%2Fw%2Fcpp%2Fiterator%2Fiterator_trai=
ts\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHKWOFdJjU1PvnpRNG8hkN993R_bQ&#39=
;;return true;">https://en.cppreference.com/w/<wbr>cpp/iterator/iterator_tr=
aits</a><br></div><div></div><div><a href=3D"https://gcc.gnu.org/bugzilla/s=
how_bug.cgi?id=3D86015" target=3D"_blank" rel=3D"nofollow" onmousedown=3D"t=
his.href=3D&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgcc.gnu.org%2=
Fbugzilla%2Fshow_bug.cgi%3Fid%3D86015\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQ=
jCNGvuk46boEAFTZ-yuAE7jYwNn0hdA&#39;;return true;" onclick=3D"this.href=3D&=
#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgcc.gnu.org%2Fbugzilla%2F=
show_bug.cgi%3Fid%3D86015\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGvuk46boE=
AFTZ-yuAE7jYwNn0hdA&#39;;return true;">https://gcc.gnu.org/bugzilla/<wbr>sh=
ow_bug.cgi?id=3D86015</a></div><div><br></div><div>This causes an issue wit=
h instrumentation of distance_type as everything must be implicitly convert=
ible to and from an int.=C2=A0 This is testable by trying to build the foll=
owing project:</div><div><a href=3D"https://github.com/anadon/Sort-Comparis=
ons-and-Performance-metrics" target=3D"_blank" rel=3D"nofollow" onmousedown=
=3D"this.href=3D&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.c=
om%2Fanadon%2FSort-Comparisons-and-Performance-metrics\x26sa\x3dD\x26sntz\x=
3d1\x26usg\x3dAFQjCNGwXzfFetG64BeOL8yIafwFThST5w&#39;;return true;" onclick=
=3D"this.href=3D&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.c=
om%2Fanadon%2FSort-Comparisons-and-Performance-metrics\x26sa\x3dD\x26sntz\x=
3d1\x26usg\x3dAFQjCNGwXzfFetG64BeOL8yIafwFThST5w&#39;;return true;">https:/=
/github.com/anadon/<wbr>Sort-Comparisons-and-<wbr>Performance-metrics</a><b=
r></div><div><br></div><div>The code of this original use case was from 199=
7 by David Musser and so was permissible when the stdlib was being develope=
d.</div><div><br></div><div>I think the following clarifications are in ord=
er:<br></div><div>std::iterator_traits::<wbr>difference_type shall not nece=
ssarily be of any particular built in datatype, but have the following prop=
erties:</div><div>* All arithmetic operators available to signed integers m=
ust be defined</div><div>* Implicit constructor from a signed integer type =
(std::ptrdiff_t) to itself shall be available</div><div>* An implicit conve=
rsion to any number type must not be present.</div><div><br></div><div>This=
 change, if found reasonable and valid, should be added backwards through C=
++11 as a clarification.<br></div></div></blockquote></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/b5426ee6-f221-4342-b346-0963828a1ba9%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/b5426ee6-f221-4342-b346-0963828a1ba9=
%40isocpp.org</a>.<br />

------=_Part_47766_841153955.1528292809923--

------=_Part_47765_2130986432.1528292809923--

.
