220 35617 <2409200.B6bFol9Gvi@tjmaciei-mobl1> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Thiago Macieira <thiago@macieira.org>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Re: Rotational shift operator
Date: Wed, 29 Nov 2017 12:38:52 -0800
Lines: 83
Approved: news@gmane.org
Message-ID: <2409200.B6bFol9Gvi@tjmaciei-mobl1>
References: <69593098-e2cc-487e-bd14-9001b27aa7c1@isocpp.org> <1660240.TqYmd56DvC@tjmaciei-mobl1> <CAHSYqdZi8AzQKRJz0b4WQcD0T1prgBtWJuJiKSn70fSgVxJvmA@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: blaine.gmane.org 1511987939 1405 195.159.176.226 (29 Nov 2017 20:38:59 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Wed, 29 Nov 2017 20:38:59 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCB4TK757YBRBXVV7TIAKGQEXMZQGJY@isocpp.org Wed Nov 29 21:38:53 2017
Return-path: <std-proposals+bncBCB4TK757YBRBXVV7TIAKGQEXMZQGJY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-qt0-f199.google.com ([209.85.216.199])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCB4TK757YBRBXVV7TIAKGQEXMZQGJY@isocpp.org>)
	id 1eK984-00089C-LZ
	for gclcip-std-proposals@m.gmane.org; Wed, 29 Nov 2017 21:38:48 +0100
Original-Received: by mail-qt0-f199.google.com with SMTP id f9sf3099421qtf.6
        for <gclcip-std-proposals@m.gmane.org>; Wed, 29 Nov 2017 12:38:56 -0800 (PST)
ARC-Seal: i=2; a=rsa-sha256; t=1511987935; cv=pass;
        d=google.com; s=arc-20160816;
        b=mZgCbHseL3cW4FrPl9AvNHOVyTdI0Y1dy7OQUwZdKuLvDy56t4r3f/pdF623AXBtTC
         UaW6chpkA9JTk2xN7Wc7EoOCQMA9vCSwzezzOoDS+pCt/PIG3EMNJhCzcbIyLmdlnQKE
         9UFhTFOPVCCTJb6q2cTNyh0ySRufFMAETmd7jEMU9ZqUZt2LCkAPn+LwWPApRJGMZC2a
         kDjeeJ95SmjpHxDe44ss6mYuyl2nZDa1gfJ2rsMMzVaHcoGINH49s7liHNZGDwhQeLuo
         ahhTbXx79HFaRXwMZeH+vVyYaxCg46tbpoe6IiXVAJd4gCzH2DjwzVS+5B6BJEBCKEGI
         M8LA==
ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post
         :list-id:mailing-list:precedence:reply-to:mime-version:references
         :in-reply-to:message-id:date:subject:to:from
         :arc-authentication-results:arc-message-signature:dkim-signature
         :arc-authentication-results;
        bh=BSkJjHPIWFQruFukYPhBn9rz6HwiyAe6A2XF7PLx8bE=;
        b=VlsJKnqpH65Bhwdn98xXwyFinI5/PCjSHDv92zHaLG23ZE3Hxz9+oq9DG+bD2w77Eu
         AB3NJrMM5tViD6EszjUSsQXkxmJZNn4hehJYJJIUx4++4deLk2rYZQzNCdQPbg+yBtR+
         hgbQabmqQVkY79HyLSrf61JK54DjYxRupJkTbYtPocm82HWt4agM1A7514bGzEQ0/0QB
         MFEwAi4AqEZuwPtM/t2ExHTc9L+VMQ3/CYKe44PagcXYbX0bwyQIcSWZRr3cdaS1MR9y
         ePy427aLbXiqRSOPj58qsut4AoH0RVD4uPOZoPTiopglqQTAK740IQV/VyDDS8Uzv3Pf
         XdIg==
ARC-Authentication-Results: i=2; mx.google.com;
       spf=pass (google.com: domain of thiago@macieira.org designates 2001:19f0:5:2221::1:3 as permitted sender) smtp.mailfrom=thiago@macieira.org
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=from:to:subject:date:message-id:in-reply-to:references:mime-version
         :x-original-sender:x-original-authentication-results:reply-to
         :precedence:mailing-list:list-id:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=BSkJjHPIWFQruFukYPhBn9rz6HwiyAe6A2XF7PLx8bE=;
        b=J27J8VvV+NLApAaSncE/76eRkRNrj9bofXeH3Uf1MhzRMlRb3gNHARuX89TbclTyuV
         fn5JWaM0bgCG9WUaWLl8bSW7e93Gv1mgMVID9zuxE1OehI8WjzYwQ+4yk2TIS3rW9Ns0
         E1bmYMRg0a9VOOjSJ30iHxzvid5qUDEM/RAe138NVazh3yul+ZZ392HeO7ZqLUAYIjgq
         P+KHWGQHSKWlJigbjRAP7fc0tIy2b6l9XTfDCq2gz3ktyRdSjkTKn2q46gEJJZOt2uTF
         DGexOJQxYPg4kCOn4az7Vi3tAv3heUiDf7aSh2PibjtzGiqBq0DCZVSaybTr3zAVDr3c
         R8nQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to
         :references:mime-version: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=BSkJjHPIWFQruFukYPhBn9rz6HwiyAe6A2XF7PLx8bE=;
        b=e2bWbUIiFYb6v6JdxqtIK0FpSKfGX7x/giu/ivULmD8LV4TXTHXz89HiABDsnuat0/
         Yk2YAC4O2AF619S7XgTQ2W2Snu9d0RJBjIErp5TIrFOj2TjMWGcoTOxgqYky7zGt8uLH
         0IkXf8/9J0FkoeBOK8KBy5PHYa/AKMo0NY+chWW5UdWn3Pt4ujkCWuAn80M7lKZjlptz
         ijEX0N6zxMo12lYqHe+Dauc02V9aOqstGU7rNdvPPC+o4yS316+Y9x03YGzf0/tr52t4
         C37NBHDA0Dh0A6mbCaabbbgM1T6GcEg5qLiLs6mWnrJplxWRLqr3i+eWcA36OWELn4AN
         W9Tg==
X-Gm-Message-State: AKGB3mIi2CyHADhVKwRm6YIu1HaO5Q+IxtqgoUelS06F0JwobzA21NKh
	0PRT8V1juhRS7p4glA4BDvwScA==
X-Google-Smtp-Source: AGs4zMbcY0sm4vwJW4lIgwf/MPrLjfGenJaBOQR3T4j+EKPNj3tesPEoo7IdBL8bjTQCl4GaWI6u5Q==
X-Received: by 10.200.24.194 with SMTP id o2mr142871qtk.16.1511987935670;
        Wed, 29 Nov 2017 12:38:55 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.200.37.177 with SMTP id e46ls11553909qte.3.gmail; Wed, 29 Nov
 2017 12:38:54 -0800 (PST)
X-Received: by 10.55.186.71 with SMTP id k68mr257525qkf.58.1511987934542;
        Wed, 29 Nov 2017 12:38:54 -0800 (PST)
ARC-Seal: i=1; a=rsa-sha256; t=1511987934; cv=none;
        d=google.com; s=arc-20160816;
        b=RXgUsj2DmSkK+AuSmkTvacKZHk83OvoZUj90Wqex3Oy6uX9n7bzkKfxlNSkMTdHDco
         pQWPbzYHVq6nL8zzuQKhw9LkS3GuVOmLS87JGZHycEsylwc6EWqOTk0U1k69FXJ+pKG6
         IugHf7s7skBSpk4j3CTgwEcnLFDxogOWguYgF593WOvr2cDSiN+ArRbvn61u/icL3yiy
         WW7r4s+eSAmfvVMjyj607nLykybIbbf3L1w3P/71Ps71nVlQcCy1Kle7jWVbZkVZNubs
         EbY/YIUsvTSwC1T9/05dfHJ7bcX9JUCPUliucNi+F1GjkhJvPXq2aKmSQwv5j7nZ/ckJ
         3c8A==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=content-transfer-encoding:mime-version:references:in-reply-to
         :message-id:date:subject:to:from:arc-authentication-results;
        bh=USJTtVTWBnSvXTstJvT3LD5Pd192HhicuGCqJzYzvdM=;
        b=jpMPMY8iZ4kK7cid4Fzgb9UsFMvsz9z+t8w0SgjdAIoWzS6+vC78ED6U0pc9m1GKJz
         QaazsxK1K0YZRsRgQCYoo4gtLZ6B2YFkfwkBTRL8TJwZ/6GSLT7ideMD/jNkHD8+n533
         lACK2HngsT5vVQ1N13At2qrpNzmHJJ9kHMBo+qShqolhuWG6RfLMwg0U2Bj1dLLPBA4M
         X8gxgeoJn3Rs+yxNu5pOR/JNk6p4pQDQNKGA3xEXwGS01Aogn6GgHBVmzhTLkPu0QHoo
         vB/d/PCSkCW7uQJ23S0t0r6Yk0GbsiH2HnBotuc83xkiWFqjawVtrKlOKC85itPHNkA+
         DX2Q==
ARC-Authentication-Results: i=1; mx.google.com;
       spf=pass (google.com: domain of thiago@macieira.org designates 2001:19f0:5:2221::1:3 as permitted sender) smtp.mailfrom=thiago@macieira.org
Original-Received: from smtp.macieira.info (smtp.macieira.info. [2001:19f0:5:2221::1:3])
        by mx.google.com with ESMTPS id z81si2770884qkz.106.2017.11.29.12.38.54
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Wed, 29 Nov 2017 12:38:54 -0800 (PST)
Received-SPF: pass (google.com: domain of thiago@macieira.org designates 2001:19f0:5:2221::1:3 as permitted sender) client-ip=2001:19f0:5:2221::1:3;
Original-Received: from tjmaciei-mobl1.localnet (fmdmzpr04-ext.fm.intel.com [192.55.54.39])
	by smtp.macieira.info (Postfix) with ESMTPSA id 030712E02
	for <std-proposals@isocpp.org>; Wed, 29 Nov 2017 12:38:54 -0800 (PST)
In-Reply-To: <CAHSYqdZi8AzQKRJz0b4WQcD0T1prgBtWJuJiKSn70fSgVxJvmA@mail.gmail.com>
X-Original-Sender: thiago@macieira.org
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of thiago@macieira.org designates 2001:19f0:5:2221::1:3 as permitted
 sender) smtp.mailfrom=thiago@macieira.org
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <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:35617
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/35617>

On Wednesday, 29 November 2017 12:10:22 PST Hyman Rosen wrote:
> On Wed, Nov 29, 2017 at 6:57 AM, David Brown <david@westcontrol.com> wrote:
> > 1. int arithmetic is no longer associative and distributive.
> > 2. Multiply and divide (when there is no remainder) are no longer
> > inverses.
> > 3. Basic identities like "if you add a positive number to an integer, it
> > gets bigger" no longer hold.
> > 4. Division by a known constant can't always be done by multiplication.
> 
> If you want specific algebraic structures, create classes that implement
> them.
> C++ fundamental types are not those.  They are a language reflection of the
> underlying CPU behavior.

That's where you're wrong. They are not.

The C++ language is defined on top of an abstract machine and the primitive 
types are types in *that* machine. Not specifically your CPU.

Besides, doing what you're proposing is close to impossible. We can't reorder 
instructions in classes like the compiler can. But they can insert extra 
checks or simply perform operations in unsigned types, converting to signed as 
needed.

> >     The mistake some people make is to think that a C (or C++) "int" is
> > 
> > just
> > 
> > >     a signed type matching the cpu's registers.
> > > 
> > > The mistake some people make is to think that it's not.
> > 
> > You are wrong.  Totally wrong.
> 
> No, you are :-)

Hyman, considering the people behind the language text say you are wrong. the 
chances are that you're wrong.

I understand you want to change that. But right now, you're in the wrong.

> > You are confusing implementation defined behaviour (which compilers have
> > to define and document) and undefined behaviour (which compilers do not
> > have to define).
> 
> I'm not confusing them.  I'm saying that it's wrong for the standards to
> make
> behavior undefined when it could be unspecified, implementation-defined, or
> fully specified (e.g., left-to-right order of evaluation).

We agree to disagree.

> > I can't think of /any/ circumstances in which it would have been useful
> > for
> > signed integer overflow to wrap around.
> 
> People use it for overflow checks after the fact.  It's easier.  What's the
> correct
> rewrite of the following?
>     if (b > 0 && a + b < a) //
> *overflow*

	if (b > INT_MAX - a)

> When something is behaving intentionally badly, that is not a
> misunderstanding
> on my part, that's a difference of opinion on priorities.  Authorities get
> to chime
> in on what should be a priority; that's what authorities are *for*.

In our case, they are called "the ISO C++ Standard Committee". I think they've 
made their ruling known.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center

-- 
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/2409200.B6bFol9Gvi%40tjmaciei-mobl1.

.
