220 23691 <4072A7C6-B09D-4847-971B-2914643B91D7@gmail.com> article
Path: news.gmane.org!not-for-mail
From: Howard Hinnant <howard.hinnant@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Default swap/hash_value
Date: Tue, 12 Jan 2016 18:54:44 -0500
Lines: 56
Approved: news@gmane.org
Message-ID: <4072A7C6-B09D-4847-971B-2914643B91D7@gmail.com>
References: <569582E5.1040108@wanadoo.fr>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0 (Mac OS X Mail 9.2 \(3112\))
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
X-Trace: ger.gmane.org 1452642897 3333 80.91.229.3 (12 Jan 2016 23:54:57 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Tue, 12 Jan 2016 23:54:57 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCK2HM4L6YERBRVE222AKGQEFKHL4GA@isocpp.org Wed Jan 13 00:54:49 2016
Return-path: <std-proposals+bncBCK2HM4L6YERBRVE222AKGQEFKHL4GA@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-ob0-f200.google.com ([209.85.214.200])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCK2HM4L6YERBRVE222AKGQEFKHL4GA@isocpp.org>)
	id 1aJ8m0-0005WE-PP
	for gclcip-std-proposals@m.gmane.org; Wed, 13 Jan 2016 00:54:48 +0100
Original-Received: by mail-ob0-f200.google.com with SMTP id k5sf62459686obo.3
        for <gclcip-std-proposals@m.gmane.org>; Tue, 12 Jan 2016 15:54:48 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=content-type:mime-version:subject:from:in-reply-to:date
         :content-transfer-encoding:message-id:references:to
         :x-original-sender:x-original-authentication-results:reply-to
         :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post
         :list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=Ey2bdfLALmfsvdjLosa+ZM6VbBsgc7Niglt2DYbTITI=;
        b=yMY2VJrLTl/syWSYJJMZgO92g6f8s4lhx2rCxf/m7auzYzyVE3NIyBI2eozpJ6BH6a
         mN9M6Q57XpKE+Y7FzvqBPtrtr3DkLNZu8RwVP+9IPttJ/OBtSCbsjTf0HYR9xUdzc39C
         +FyyzUgDI+mW7GirS/ioniCJT4mqX4ysr1BU4RfxbcWGehOSgU6WIr4a3QY9FVjXS9JS
         PTSZsCX+7+OXqC2Sp5ORs8zNJOOv20qxu7y8b9hwJqCccksA8QtJ1JFiULZ+vxtuQglf
         3S/SCoo/hefR5oB0x/gUl8MuUI8kS2wWCCCuCZE5u7HA/cmKOfWaqATBaGGof324QWwN
    
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:content-type:mime-version:subject:from
         :in-reply-to:date:content-transfer-encoding:message-id:references:to
         :x-original-sender:x-original-authentication-results:reply-to
         :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post
         :list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=Ey2bdfLALmfsvdjLosa+ZM6VbBsgc7Niglt2DYbTITI=;
        b=ExSMwwpDFdnpS5IVH2RJr0Rq3vJAFkx34JPtDeL4P7cJzAaVDawjAKTyOWoSV/FhYH
         EZfZa4da8wZHHLFyKJXJOAPOKxNpFuH2tnwxQ4SwZ9o36wlDw4/OH8COk+aBgrpUlhoq
         3wlJP8h5pdekz5xFWSNHw/p3PSkosleBH+MG2Pa+KEEZFDaqQUPa/ahpLJ/0h2e5kXy0
         mzQiJonBbH5sY47+ZqGbpXEQlQXJKjRh20oPPzD7bQ/uF7gGu3vNjkdUxMZRB8n2aAvn
         +9/6OSe6NDTxYs4vptW+wecWpMbOZhZKzWXxk5neviBMCrzm7OqnYw/9c7vc6WoYPmZ/ 
X-Gm-Message-State: ALoCoQnUg+P4+GfHcXSFlHi6vriFsQL6CHfWUJrT7UmRXbC+LP4ph63w2EJ55RWHNH+Nb5GtHDkfuoqW0Di59AX0cH2q0laviA==
X-Received: by 10.182.142.8 with SMTP id rs8mr97366669obb.33.1452642887852;
        Tue, 12 Jan 2016 15:54:47 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.140.98.173 with SMTP id o42ls15727672qge.95.gmail; Tue, 12 Jan
 2016 15:54:46 -0800 (PST)
X-Received: by 10.55.21.143 with SMTP id 15mr29774183qkv.74.1452642886380;
        Tue, 12 Jan 2016 15:54:46 -0800 (PST)
Original-Received: from mail-qg0-x233.google.com (mail-qg0-x233.google.com. [2607:f8b0:400d:c04::233])
        by mx.google.com with ESMTPS id g13si2260833qhc.69.2016.01.12.15.54.46
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Tue, 12 Jan 2016 15:54:46 -0800 (PST)
Received-SPF: pass (google.com: domain of howard.hinnant@gmail.com designates 2607:f8b0:400d:c04::233 as permitted sender) client-ip=2607:f8b0:400d:c04::233;
Original-Received: by mail-qg0-x233.google.com with SMTP id b35so312489985qge.0
        for <std-proposals@isocpp.org>; Tue, 12 Jan 2016 15:54:46 -0800 (PST)
X-Received: by 10.140.105.198 with SMTP id c64mr15393700qgf.94.1452642886256;
        Tue, 12 Jan 2016 15:54:46 -0800 (PST)
Original-Received: from [10.0.1.2] (cpe-104-229-168-124.twcny.res.rr.com. [104.229.168.124])
        by smtp.gmail.com with ESMTPSA id s90sm3790464qgs.13.2016.01.12.15.54.45
        for <std-proposals@isocpp.org>
        (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128);
        Tue, 12 Jan 2016 15:54:45 -0800 (PST)
In-Reply-To: <569582E5.1040108@wanadoo.fr>
X-Mailer: Apple Mail (2.3112)
X-Original-Sender: howard.hinnant@gmail.com
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of howard.hinnant@gmail.com designates 2607:f8b0:400d:c04::233 as
 permitted sender) smtp.mailfrom=howard.hinnant@gmail.com;       dkim=pass
 header.i=@gmail.com;       dmarc=pass (p=NONE dis=NONE) header.from=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:23691
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/23691>

On Jan 12, 2016, at 5:49 PM, Vicente J. Botet Escriba <vicente.botet@wanado=
o.fr> wrote:
>=20
> Hi,=20
>=20
> I've been working on a proposal (see attached document)
>=20
> Default swap/hash_value
> Defining swap and hash_value P0029R0 as well as comparison operators, as =
proposed in N4475, for simple classes is tedious, repetitive, slightly erro=
r-prone, and easily automated.=20
>=20
> I propose to (implicitly) supply default versions of these two operations=
, if needed. The meaning swap is to swap each member, and the meaning of ha=
sh_value is to combine the members using hash_combine.=20
>=20
> If the simple defaults are unsuitable for a class, a programmer can, as e=
ver, define more suitable ones or suppress the defaults. The proposal is to=
 add the operations as an integral part of C++ (like =3D), rather than as a=
 library feature.=20
>=20
> The proposal follows the same approach as Default comparison as in N4475,=
 that is, having default generated code for these basic operations only whe=
n needed and possible would makes the language simpler.=20
>=20
>=20
> Any comments are welcome,


For the hash part:  How does one switch to an alternate hash algorithm for =
type T without having to revisit the code for every base and member of T?  =
This is the most important part of both http://www.open-std.org/jtc1/sc22/w=
g21/docs/papers/2015/p0029r0.html and http://www.open-std.org/jtc1/sc22/wg2=
1/docs/papers/2014/n3980.html.  If the std ropes people/programs into a sin=
gle hash algorithm (as it does today), then all of that code is vulnerable =
to attack.

Only by allowing coders to change the hash algorithm for type T with O(1) e=
ffort can C++ ever hope to stay ahead of the arms race in software security=
..  The C++ committee itself is too slow and cumbersome (by at least 2 order=
s of magnitude) to supply (or even suggest) the best hashing algorithm for =
code that must hash values from untrusted input.

Howard

--=20

---=20
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 e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at https://groups.google.com/a/isocpp.org/group/std-propos=
als/.

.
