220 35575 <1887594.mdY3tAJtOz@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: Rotational shift operator
Date: Mon, 27 Nov 2017 15:49:15 -0800
Lines: 56
Approved: news@gmane.org
Message-ID: <1887594.mdY3tAJtOz@tjmaciei-mobl1>
References: <69593098-e2cc-487e-bd14-9001b27aa7c1@isocpp.org> <38eba22a-1305-4b45-86a8-2d2e3c9f26ae@isocpp.org> <CAHSYqdaAES0LCWfb7FJjcOy_qo8mQh003uBACcoT42s_PQtFww@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 1511826560 16743 195.159.176.226 (27 Nov 2017 23:49:20 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Mon, 27 Nov 2017 23:49:20 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCB4TK757YBRB7OI6LIAKGQEIPL52CQ@isocpp.org Tue Nov 28 00:49:15 2017
Return-path: <std-proposals+bncBCB4TK757YBRB7OI6LIAKGQEIPL52CQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-qt0-f198.google.com ([209.85.216.198])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCB4TK757YBRB7OI6LIAKGQEIPL52CQ@isocpp.org>)
	id 1eJT9D-0003es-6M
	for gclcip-std-proposals@m.gmane.org; Tue, 28 Nov 2017 00:49:11 +0100
Original-Received: by mail-qt0-f198.google.com with SMTP id g49sf22352006qta.8
        for <gclcip-std-proposals@m.gmane.org>; Mon, 27 Nov 2017 15:49:18 -0800 (PST)
ARC-Seal: i=2; a=rsa-sha256; t=1511826558; cv=pass;
        d=google.com; s=arc-20160816;
        b=vrq4eR8qDUIoEDLmeOweXXT9SaodrYfLUfDCpAtwanHds8Jr4FK5rKXwDQ7Cs3VBh3
         SLUnvgBAP5C8wsdpkgQlO4vPp+oSDJzofKpKYrruWRhW3EO4m5bSWp/wLPqGZ2KEfPhL
         QU+AE0yxISSfr45eu6eAvzH1ekfxOy/XCa+5ucdj+D8nxzKxUm/Fw4Amh9FRdHCz0nDf
         5Gcw3oZ3yR1XQ3nDVKaW553FqqOdZli2N2ZPWcR9y4k3TGtZYfJkTje05N/gm5Ehp7ki
         hUPB18w08nRA1ok0IDzzhMesTIxQn1aj0vHgSz/Glkr1BjgPCwq8aHwxhxnVUzw1QNDt
         s1Bg==
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=kUbJW6T2wmd8tHmR9tu+59r2T5cbpRtVfu4h/NteN74=;
        b=ylE6bm1IxobQbZVnX930wyy1WNLWpZO03ld5MJ0z7pcou7vOtboX+hGzw8xrC7hvj0
         x7vGLj+KcfUQfYndEA9RpolxuoPloD0mfy1ZqPMe+sjeh/KM5yhyYASi0h2FGLbKhDtr
         4dyvNpyunbd/v8/Rq+LQkK0jL/iZe2DJIEOocfMUZxadLMOianosfQdKp/OR3LmeCjZ6
         ngKB5/yjFz+G7iEl13m/azwgCUViwc8t6fBFWHJV5RuLKdPv6B9Pktm5rvTNYW/MLNiy
         dl4WiXF0UAEMohAs/oaMVB5ISPqn0zmFHKRe+zc67nX44vsskVw0t1SG6spSnekCbLqJ
         NPkw==
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=kUbJW6T2wmd8tHmR9tu+59r2T5cbpRtVfu4h/NteN74=;
        b=RdzfNKAix54BkC3camFhjkZwfIMDLkzsuzI6rRm7SD/tkwhiNH5tDBREK6S1j8Xr02
         a6H64XMYs5qJ3LemhLL+mQ+8HNRdGr6zPDbpH93ym/5BmqA8KUz2bSIURndWyKd7Wlnl
         TUj48O7unsQY15UC9ex4ocPvZ2bu27L7EFWe9b0PTyAdCKW7YtJlWuumNHC4f8p8nlIv
         /OxNkGQIpt/LxYhKOvCLbs4KMi59K09fREXbBe2SrJUSscujGLylgEoe1gsL3k946Fr9
         J2Q9LXTw6CbNCwHtK9EVLJCAAm1rRdtxW1UFNZWwbfhWb+Uf6YbCX9kzSNBQIENy2Hh3
         DHgA==
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=kUbJW6T2wmd8tHmR9tu+59r2T5cbpRtVfu4h/NteN74=;
        b=stwOEAxEXAPMQEaZQ/n/fRJheT2BxZpA8xdqAfB/62pFwIdbwtMM76XILfcuXcptLn
         rAhEnIS2JK75qTskOAvvzXpEhLJJXWMPIvkNWxpZq9PZ1yj0FSJUofGQ/8AF1EFE0IWb
         /u8lDj3kkE5KQGweQDv4aXaEAIuXLXoGH1dtgOYJIUtwKHfHhkz5Rn/F+1XBRINVhlMV
         PkivsVeQJrQ7sxwIZprDSn0CT5rAIpWs0Wo2Ra5pR0gFvmyGF5d+0DsFRwRcVny7X2Ub
         Q00kQq+Rk757W6uQ0MWaLgbXsPM6idyv4bdjPxZA66SkcPL1FEtjlCB6NYcqAXslKPv/
         HrXw==
X-Gm-Message-State: AJaThX6KJYO8jWFGhniiTklxz0B9JvN/99KqGWVgl1uV7rSvSGLv6ekg
	chil4hzEhQocgfgj9Pg8M3f4Eg==
X-Google-Smtp-Source: AGs4zMaq/rSMZyXNODZbkxN/VJ3vWOE+RDVGFHEmpu7mHVwPX3sZWe9/DPDUVzfUjYsK/9TvUnvUfA==
X-Received: by 10.55.197.11 with SMTP id p11mr33146642qki.59.1511826558364;
        Mon, 27 Nov 2017 15:49:18 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.55.109.198 with SMTP id i189ls8332114qkc.9.gmail; Mon, 27 Nov
 2017 15:49:17 -0800 (PST)
X-Received: by 10.55.153.3 with SMTP id b3mr32897531qke.230.1511826557621;
        Mon, 27 Nov 2017 15:49:17 -0800 (PST)
ARC-Seal: i=1; a=rsa-sha256; t=1511826557; cv=none;
        d=google.com; s=arc-20160816;
        b=WykMEPHbFtJqyton1J5Kg0ZPXXkTz7dirrW+rBqbAOG6xXlAKpnq2AjxykdUEiZnCM
         R6Ke7GTHq3Yw2DZja9C7sFmcmnjI1YOfrkwHIpQ28KFTbXgt0V8YCkpe1LseRQFJeGZj
         +NidDpEtH/WdK0sr9VXIybY9ob7i/nO665ix1xMA1/i+5Y8u6RDF4el1JN6pk03Kl4Rg
         UBoT+Sq8bfIOKWs7KzvPryWo+1j1rclSbQjcvG1QGqSCT31Bo1xfvdKXxFfhvapuva/2
         rA7p1jTNuNKK6bLerlSsfKclVzy4/XbU55fknd/ISIRD3hWK/kv+PF00zxgydbfkd1rO
         Ki+w==
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=QyfSYg9SaNvXQ6spVnIvJATf5ma8pqZE5A1JVwLytsU=;
        b=wn5LJ3Yiir1pFx1pwqUEBTO/XgXImqaFRbUIGOPpcwceeJM+NqN/QIADDaS4omShLy
         37CzPRG9DFwJkMcD+AN2BtDKeQYDh1SlZkVY3dZdG34t7pmGm4Izj29E8rsiQWYYaAwO
         unNb6kLKr4OGsg2SUCAKg6dEt9rXEgMb3oIp8RVqpkoDvz8UmBj7wG5IUk9tXjQhpLxZ
         hTBJLBMiOld9VbTBCKzw/cLVjwNc4wy+Qxu2JdLhruFRoOqo0cVkovfH17m0ta1cBcke
         arGlKEzH2eWA6Y+JYZNneeCNXR0poPtcY19hesHVj0rvuwYjxwGOtSo/5eS1307jBszH
         AiDg==
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 z81si11269923qkz.106.2017.11.27.15.49.17
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Mon, 27 Nov 2017 15:49:17 -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 (jfdmzpr03-ext.jf.intel.com [134.134.139.72])
	by smtp.macieira.info (Postfix) with ESMTPSA id 93C242AC9
	for <std-proposals@isocpp.org>; Mon, 27 Nov 2017 15:49:16 -0800 (PST)
In-Reply-To: <CAHSYqdaAES0LCWfb7FJjcOy_qo8mQh003uBACcoT42s_PQtFww@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:35575
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/35575>

On Monday, 27 November 2017 14:15:48 PST Hyman Rosen wrote:
> C compilers were intended to be "close to the machine," so their arithmetic
> was supposed to be "whatever the machine did."

No, they were not.

C was designed to be "portable assembly", which meant it's not "whatever the 
machine did" but instead a known set of rules known to work the same on all 
machines. Sometimes that meant reducing to a subset of what the machine could 
not, sometimes it meant some machines needed to do more work compared to 
others.

> Signed overflow was
> formally undefined because compilers could run on hardware with
> 1's-complement arithmetic, or with hardware traps on overflow, or whatever,
> and defining the effects in the language could badly penalize programs
> running on hardware that really wanted to do the arithmetic differently.

Right.

> That's qualitatively different from compilers deliberately adopting a model
> not represented by the hardware in order to *cause* programs to have
> undefined behavior.  On a processor where signed overflow naturally wraps
> around (which is virtually all of them), the compiler should not make
> signed overflow be undefined behavior and then eliminate code which checks
> for overflow after the fact.

I understand you believe this, but that's not a shared belief.

Others believe that, since the language says you cannot do something, 
compilers are free to assume you did not do it.

> And programmers have from time immemorial wanted to overlay different types
> on the same area of memory and interpret the object representation of one
> type as the object representation of another.  In Fortran, they used
> EQUIVALENCE to do that.  In C and C++, they used unions or just plain old
> casting from one pointer type to another. (That's how the X Window event
> system works.)  Taking that away in the formal language definition doesn't
> change the fact that people want to do this, have written programs that do
> it, and that those programs break at the whim of compiler writers, who are
> there in the meetings to make sure that nothing gets into the standard that
> would "negatively impact optimization."

I agree we need a way to fix this, since we need to do that. That means 
specifying the behaviour properly, not getting rid of all UB.

-- 
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/1887594.mdY3tAJtOz%40tjmaciei-mobl1.

.
