220 35618 <1971370.BddXmUsGWe@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:42:10 -0800
Lines: 48
Approved: news@gmane.org
Message-ID: <1971370.BddXmUsGWe@tjmaciei-mobl1>
References: <69593098-e2cc-487e-bd14-9001b27aa7c1@isocpp.org> <1660240.TqYmd56DvC@tjmaciei-mobl1> <659853f7-4d67-4cbc-4632-1a7cfc532f44@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 1511988131 16241 195.159.176.226 (29 Nov 2017 20:42:11 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Wed, 29 Nov 2017 20:42:11 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCB4TK757YBRBJFX7TIAKGQEHGBA7EI@isocpp.org Wed Nov 29 21:42:07 2017
Return-path: <std-proposals+bncBCB4TK757YBRBJFX7TIAKGQEHGBA7EI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-qk0-f199.google.com ([209.85.220.199])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCB4TK757YBRBJFX7TIAKGQEHGBA7EI@isocpp.org>)
	id 1eK9BF-0003nw-I4
	for gclcip-std-proposals@m.gmane.org; Wed, 29 Nov 2017 21:42:05 +0100
Original-Received: by mail-qk0-f199.google.com with SMTP id 132sf2940326qkl.15
        for <gclcip-std-proposals@m.gmane.org>; Wed, 29 Nov 2017 12:42:13 -0800 (PST)
ARC-Seal: i=2; a=rsa-sha256; t=1511988132; cv=pass;
        d=google.com; s=arc-20160816;
        b=XlaHYY8E0+Ia/+8BI/q9p96g6Ym39FnI9WvLOWR1t+UeiCPzSuWIC+qycw57oUorZS
         POV4oXjQ8Q01tfeYgnTWFod3w4Om2nB5Jb49mjNvyrIULs3TDpHJIXH0legkc0D6qXab
         uXwlrsjNc14d70Y+majXyaiNwM0RaG9n4O949YiagUvncceEL8Cp1U1klQ/+0VjJJ8Wu
         S7+lyQltZFK1QHwx9IQ8SoYzLY5d2wGAKa5KdwTEgY1w6HIgjYQ8w4X2Zy6gl5wINd6n
         wili4d4gfQcx/0OKrZ68bE+PLpUStQAyt3PCLQ0dkccdX2i3q4EfMZOccyn9DCebz9U1
         EvkQ==
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=Iopz6fMKpg3ZAEMYjZejCc+9QxK/FuW44ZH7xI5GkQ8=;
        b=YoMfXd78KbJF0IJULzie0/bkutef5EFlHS8BPwZo3icE9+miAvUii1kOuB+FTjc6l9
         otcGWNEUc0iSTfwcTUJFa/i+TpRFMEV92WZ+xAJ5IP2MeFLq+wM08BQVafXEx/DG4wfn
         OCBlray5gE7Cga5MPOlRnuQ1Zbb+FeWDk73PROFR7JrndIJXIm0QvVbpMOG7ldR960Wo
         BcHADY9NSE12lYP3JSgn8KRwg7TfsLYucVM2hr2YceMx2jMvAONz8VheL5UNcY2XTXo+
         5exY/9eBlG5bwfJdWaXuomuMj10pZjR05NOFWe2rXUWwOmpcgJuW/Hx0Lu/urgbLg+ve
         LQbw==
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=Iopz6fMKpg3ZAEMYjZejCc+9QxK/FuW44ZH7xI5GkQ8=;
        b=X7To4MUy5s9QC3jtdN5gvhllbZbYy1uYAi5v3ipB419bxCd8jbJ2MZyhs1QPY1ErfD
         mMFZQveoK6WVvlNNXLDloP9hAOLpbjGoeQfSkXOgGiptV9vrn9b3FluhUv3Z4TeKrx3a
         cH7FEMgJfgbDE+uI+rCBUXlm8SXR4s/z+0vbx/1gsGz7F85p2dHSVFIpQ/LaBHFRLFsT
         ziKnjWHmw5U/THITiz6BxD5I3W04YBqucbMKh1CvOcjCTqYts/JqJIM5B4TsiBLHuJT+
         JepfUmrEWWvPaj1cC/0JKwLEzOSA5CI10jrvhUh8m3Jq+g4Hj1oZX885uofvvg7GIsa/
         DfKA==
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=Iopz6fMKpg3ZAEMYjZejCc+9QxK/FuW44ZH7xI5GkQ8=;
        b=VAcCbLtMiJkPUWUxh8ekx8D/wnFhjWvdmn1LtYDATIS758RtU9pUrR5H03zvaAPkDO
         Yaxjd9maFPPeWmcBC2zB5UtOTp7vDB1CB48DCi5YT/zPWCBIpO6bIrQUKRkfbc72yxkl
         wSqIlUBOUDoN6cyZQH9DIy4xakxBwYo9qrTdyJNzihYYx0Dtq0O5s56TEMlw5yXtyeGU
         K55kmjjJ1KUp37fn5bkXPW6zlu6/llBhOgg8ASRL7oDrDEcdmY+iym6I3TWrAU4Hz7wp
         UYd9KIdue/5bwjn0+XcTn0Ts9Gkuxuiq0QWMc3QWJT2yxZAgLVtUYI9LYztunhmLM7iY
         yesA==
X-Gm-Message-State: AKGB3mIR64Xgp+N70DruIGNxLjMpzgj7EvT6Es/Q7FLBwEdI2fQCxPvM
	souMX91WOSTgL5KIWx5n+fTlyg==
X-Google-Smtp-Source: AGs4zMbTsHn2Dd+3OHr35N1t34fuad3AXCjrRY3n67tPl+/2iXeelANvC258rDUbTl25LmSDokeL+w==
X-Received: by 10.200.39.76 with SMTP id h12mr135063qth.60.1511988132784;
        Wed, 29 Nov 2017 12:42:12 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.237.62.110 with SMTP id m43ls11554478qtf.6.gmail; Wed, 29 Nov
 2017 12:42:11 -0800 (PST)
X-Received: by 10.55.127.71 with SMTP id a68mr248185qkd.90.1511988131976;
        Wed, 29 Nov 2017 12:42:11 -0800 (PST)
ARC-Seal: i=1; a=rsa-sha256; t=1511988131; cv=none;
        d=google.com; s=arc-20160816;
        b=jsm03eP+psNHPXNXPEEjoxHgiEr2s0RSAhu4jSuAuqy/tQwSoKFn5HLM0La96VsVeA
         4k2pExBhumlvuQqNJXrtdrqlGy+6d9ZrcbrCFmuzXY4uNdKPVzwvZcT+tKnbquTGadrG
         6vXwipHOkNmEof4tkOSIVsAMNusa8YjzrRMvWFVhWHdz76pdxE7fWai4bnqAELTS8CRj
         CsbqWXdhyKsA4f+esdjfcrzWxyPOQOkKZxKC7OYQ8qsXxe5YUk+jWNe4+ZdZMZvjWy74
         z0t2nm1zY3c8Sah+q/UpN0+1MfatJD7fZoT2gX+0Hlr4i5FkbS/+fQH1VO6n14negnob
         9gIQ==
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=xk0Pjz5t8f774OVjAcv/lpHrt87g7Bbm13OyJvrqWyE=;
        b=lUDlsnbD8bU8i29IAdRHhuuysMrdVqPdkV6XgMRAo4YIzjALVqYwxAC/2lmFGhURLe
         6Ty0CT8RXcPjcyfZKbM+0GENBHndp89+wdoo6SwckY9Gu7npTZ0GCT1+CJkOTgWx8PI1
         qC4O+ZMWryD/pzjJPm6COS5IN9h6gKtJlBEHGhaf6BGSO6NG7tdDnXSi0tlo0t/STzbL
         aINttnBjEjQDa12GY1HNGA6KU8wV9b/1O6/PhONoXefqbgLXSbxkowPkuZLX9/J2aXeS
         VPduGZqMNcI9OEDJtsCmJs+X3s/22wQaMn+o2EF3SrY7iC/y2n29k1FuirynxD3RKbZe
         w4Fw==
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 41si2033118qtu.188.2017.11.29.12.42.11
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Wed, 29 Nov 2017 12:42:11 -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 9006A2E08
	for <std-proposals@isocpp.org>; Wed, 29 Nov 2017 12:42:11 -0800 (PST)
In-Reply-To: <659853f7-4d67-4cbc-4632-1a7cfc532f44@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:35618
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/35618>

On Wednesday, 29 November 2017 12:36:22 PST Andrey Semashev wrote:
> On 11/29/17 22:41, Thiago Macieira wrote:
> > On Wednesday, 29 November 2017 11:08:38 PST Matthew Woehlke wrote:
> >> I can already hear people screaming that they don't *want* the compiler
> >> to optimize. Well... go write in assembly, if that's what you want.
> > 
> > Just use unsigned if you really meant to have the overflow semantics.
> 
> Unsigned is unsigned, why would you have to convert to unsigned integers
> to handle signed overflow?

Because you can.

	a = b = INT_MAX;

UB:
	c = a + b;	

Totally valid:
	c = int(unsigned(a) + unsigned(b));

Since the conversion back from unsigned to signed is IB, you can compare 
against a and verify if it's smaller.

	if (a + 1 > a)		// constant true

	if (a + 1U > a)		// comparison remains

> > Converting from unsigned to signed is completely defined if the result is
> > in the positive range of the signed type, and IB if it's outside. Since
> > it's IB, you can rely on the result being the same across compiler
> > versions and optimisation flags.
> 
> Implementation-specific behavior is not portable, it cannot be relied upon.

Indeed, but that's what Hyman wants: well-behaved but implementation-specific 
behaviour.

-- 
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/1971370.BddXmUsGWe%40tjmaciei-mobl1.

.
