220 38518 <5bceda10-ca60-4100-8fb3-16fcb8713552@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: Clarification of std::iterator_traits::distance_type
Date: Wed, 6 Jun 2018 04:46:12 -0700 (PDT)
Lines: 84
Approved: news@gmane.org
Message-ID: <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_47106_1069134468.1528285572033"
X-Trace: blaine.gmane.org 1528285450 4054 195.159.176.226 (6 Jun 2018 11:44:10 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Wed, 6 Jun 2018 11:44:10 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCFIZIPVQEORBBMT37MAKGQEJIKMJGI@isocpp.org Wed Jun 06 13:44:06 2018
Return-path: <std-proposals+bncBCFIZIPVQEORBBMT37MAKGQEJIKMJGI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-yb0-f199.google.com ([209.85.213.199])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCFIZIPVQEORBBMT37MAKGQEJIKMJGI@isocpp.org>)
	id 1fQWrD-0000t1-5O
	for gclcip-std-proposals@m.gmane.org; Wed, 06 Jun 2018 13:44:03 +0200
Original-Received: by mail-yb0-f199.google.com with SMTP id f141-v6sf4486605yba.15
        for <gclcip-std-proposals@m.gmane.org>; Wed, 06 Jun 2018 04:46:14 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=date:from:to:message-id:subject:mime-version:x-original-sender
         :reply-to:precedence:mailing-list:list-id:list-post:list-help
         :list-archive:list-subscribe:list-unsubscribe;
        bh=RGW/lCe4Jxv/g2KCoF7u0Mirb7FtuiZ0pgCEirvfy3c=;
        b=KQo47B/gnCraPBcwrRvnt9zfRs/FSVmtTVDopDZ+D4mfPZq8aeUqkBY3i/V3DEujuv
         HeLrJeIzXpWdNS+AxL2dmkHDk5/K9QAOIxRS3jTBeWhxQouSKUCwIhcFxf5RM1Y/ECuy
         XnhqQWMRdzJmjoHvq3iIHrtbVF/3DR+5akRIXIW6uDm7K+km1PaIHQvgRP6kwt2xYcFD
         AfvlaRwUTdmtYClkK6QnSJO1sehJ8ZtYrynP+II0kdr6/vL17klhT1YliKHK1Gj5wTAl
         /cOI3RHq80OTRVcLgg/pC+abheTSEaccaZw5+YRhoxV3ZyN33nEGZKVZOfQHLq5WTEG6
         nq3Q==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=date:from:to:message-id:subject:mime-version:x-original-sender
         :reply-to:precedence:mailing-list:list-id:list-post:list-help
         :list-archive:list-subscribe:list-unsubscribe;
        bh=RGW/lCe4Jxv/g2KCoF7u0Mirb7FtuiZ0pgCEirvfy3c=;
        b=R8m3nTZQ0OJNBA1CkkLN8Ac4YgDZyD2001w+mvLQtef6jVDZoAIw7hMcd2M7MvcaDC
         ZtfXq3fIVlKrx4oMVYcL709FiMsMJws+VM2BcFlQt/3cnCnYUmE4iZ+jBgPe10zIYO/P
         Q+Fqvwd5dQ1xHSRJn3tk+wbebA8OHxZ/LmQRJzqx+KDq2+d7x/xDGAzbYfjbR00JWmFQ
         VfQwh/rS2Oqaeo0QQuNyS3wuTDGmVL/eUUHaUteChvxRUNr5xZCcWQ8yEY2moZJQ0Muq
         mxzEQJ0CVu5QlVKKhM5SmFGi6tgGbWe4jUhNWU+WLwgDTAPG+rDIWS12Uwh0/J+DjRQn
         4XqQ==
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:message-id: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=RGW/lCe4Jxv/g2KCoF7u0Mirb7FtuiZ0pgCEirvfy3c=;
        b=NFZG5eyaPelfzJ1Oxu1s2Bsm1+PZ3M4yDSrVGN6R3sBDVFXpFxRxVTlZTFnx6ynCLe
         P8I8355Ys7suyh17SzHH21UNTUNbUXDDlGwwNA+RzEO/4Sr7oh1vNwNOhHWgA0PWewOH
         TEa7crThzN0uzec3wryxwq0El0PEVQ1l3igbnpkhPRGyune6U/mi5fpY9Dhb03dERjCN
         6/GnlmtRdKu6/UfLEHew2U03BN0WRTvLk4t64SmKfclvGn5y7VXLGeOcWAguDdqO/1XT
         mkgYJgMNDygcFczbxaTKDGSBIxsbVV8c9qxRPwM+NIiohH6X2i/msILFO9gR197IGmMC
         cClA==
X-Gm-Message-State: APt69E2v1cSv5w8ZkwrweHctqumpse0LgcipismU4UoUOEK47Z3B+fpx
	X6YUf3cFrvisBY0vWwUpFnKqBQ==
X-Google-Smtp-Source: ADUXVKJPm0V4DH6jMw8vj0XQzuC5bRAFvW4XeSipmK4M+QHUfupMTxTombAmSp0tnNDjfUyi7gQXlQ==
X-Received: by 2002:a25:be12:: with SMTP id h18-v6mr737254ybk.62.1528285573965;
        Wed, 06 Jun 2018 04:46:13 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 2002:a0d:ddd7:: with SMTP id g206-v6ls3628060ywe.28.gmail; Wed,
 06 Jun 2018 04:46:12 -0700 (PDT)
X-Received: by 2002:a81:9c58:: with SMTP id t85-v6mr115892ywg.12.1528285572652;
        Wed, 06 Jun 2018 04:46:12 -0700 (PDT)
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:38518
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/38518>

------=_Part_47106_1069134468.1528285572033
Content-Type: multipart/alternative; 
	boundary="----=_Part_47107_824776385.1528285572033"

------=_Part_47107_824776385.1528285572033
Content-Type: text/plain; charset="UTF-8"

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/5bceda10-ca60-4100-8fb3-16fcb8713552%40isocpp.org.

------=_Part_47107_824776385.1528285572033
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>There is a bug in glibc which seems to have arisen fr=
om ambiguity about distance_type in std::iterator_traits.=C2=A0 It does not=
 have defined required operators or constructors, but is implied to behave =
line a signed integer.<br></div><div><br></div><div>https://en.cppreference=
..com/w/cpp/iterator/iterator_traits<br></div><div></div><div>https://gcc.gn=
u.org/bugzilla/show_bug.cgi?id=3D86015</div><div><br></div><div>This causes=
 an issue with instrumentation of distance_type as everything must be impli=
citly convertible to and from an int.=C2=A0 This is testable by trying to b=
uild the following project:</div><div>https://github.com/anadon/Sort-Compar=
isons-and-Performance-metrics<br></div><div><br></div><div>The code of this=
 original use case was from 1997 by David Musser and so was permissible whe=
n the stdlib was being developed.</div><div><br></div><div>I think the foll=
owing clarifications are in order:<br></div><div>std::iterator_traits::diff=
erence_type shall not necessarily be of any particular built in datatype, b=
ut have the following properties:</div><div>* All arithmetic operators avai=
lable to signed integers must be defined</div><div>* Implicit constructor f=
rom a signed integer type (std::ptrdiff_t) to itself shall be available</di=
v><div>* An implicit conversion to any number type must not be present.</di=
v><div><br></div><div>This change, if found reasonable and valid, should be=
 added backwards through C++11 as a clarification.<br></div></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/5bceda10-ca60-4100-8fb3-16fcb8713552%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/5bceda10-ca60-4100-8fb3-16fcb8713552=
%40isocpp.org</a>.<br />

------=_Part_47107_824776385.1528285572033--

------=_Part_47106_1069134468.1528285572033--

.
