220 35726 <2686086.MHsyEc3O6d@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: Sun, 03 Dec 2017 22:28:15 -0800
Lines: 69
Approved: news@gmane.org
Message-ID: <2686086.MHsyEc3O6d@tjmaciei-mobl1>
References: <69593098-e2cc-487e-bd14-9001b27aa7c1@isocpp.org> <2168917.U4FlfNKMk3@tjmaciei-mobl1> <CAHSYqdYGp2CzV5NgCwsrD34A1eEv50-vMNXqUv3B7E=QmHqbCw@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 1512368900 19037 195.159.176.226 (4 Dec 2017 06:28:20 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Mon, 4 Dec 2017 06:28:20 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCB4TK757YBRBAWWSPIQKGQEWZ23APY@isocpp.org Mon Dec 04 07:28:16 2017
Return-path: <std-proposals+bncBCB4TK757YBRBAWWSPIQKGQEWZ23APY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-qt0-f197.google.com ([209.85.216.197])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCB4TK757YBRBAWWSPIQKGQEWZ23APY@isocpp.org>)
	id 1eLkEe-0004WS-LM
	for gclcip-std-proposals@m.gmane.org; Mon, 04 Dec 2017 07:28:12 +0100
Original-Received: by mail-qt0-f197.google.com with SMTP id 11sf11275407qts.15
        for <gclcip-std-proposals@m.gmane.org>; Sun, 03 Dec 2017 22:28:20 -0800 (PST)
ARC-Seal: i=2; a=rsa-sha256; t=1512368899; cv=pass;
        d=google.com; s=arc-20160816;
        b=iecK1AtDJZ/L32snh3IqK8dBxvUK4UZGzdJtZjtvdvauu9AG5FdZjE0r8dDZ2t0fts
         ngUyUAgAHl+4sSejznjFyTo+7GMAYk1xgin/rqwBxVSCSD9vTGTt+avs8OC1/lokDHZT
         wZlvmQbEcEgAOaZVF/KIGVUHecKv89/wmkGixQaXGcha48HeRhkeArGMZ902xqdv3lcY
         E4Iu5C1Oy+V51gppo6VzDZdR8DcJsf0Uy2HFfRE5HQ7ON8Jqsr2RW18t0nO0Vk8ZHJN9
         c8MjwBKx6iQ7JJ+IS1xJ0OeegD3SzOUUlvh0IHwd/FUT25fou0Hs8f0c4x586rKg8nyc
         1yPQ==
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=sZ2lc4ODAfIKlu23mUsVtS29kErwUbVbfljD8tISSnQ=;
        b=fn3pZ+8MaIfOPdeSSu4LX+nHCtY6emmTVqJgMrzru8V5eRobnKN10j62l6x0IbmEMa
         /1rLQmIY0Yxz+0i93zEqlFQFlSfVzA4+WTNjF6vgxPufNhCGQvmCh8w1zdKcAdyBuOIP
         UUkINMJkVU3phXcGcyQbxxtXMcQTu7itHmpEiJbwNs7KFLFuM/GLRiX0U30bw+iPXi4T
         Riugl4S6ZjgKoyKDB9t0SVc7qtLVjOxa++vr0N7V0rvCca5L6VjXlzWvl51pzFfvU7Ke
         SqpbWLTLmMAFvNf9SRYfLTJqnS5RnuWN1C8ZH4BnGIYpzqL70NOHktvURx0KMWtaz85J
         s5fA==
ARC-Authentication-Results: i=2; mx.google.com;
       spf=pass (google.com: domain of thiago@macieira.org designates 209.222.10.136 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=sZ2lc4ODAfIKlu23mUsVtS29kErwUbVbfljD8tISSnQ=;
        b=W5V5beFKYvL7njPcezzjYE9MeOlss8TQWRSQwwTlw2uL0M5SYEjn1lPgzcpaoA1c0J
         WDRjlizm4GbasdPo1BnHOnhaRut8u5y6i6YtQT/ZE9ZSCZRwicIArSoh90mSL4ZirccY
         Tc6XT4GTZgM3h1wEJqLK0hCcUz8mXQamFwCb3Of5Al2o9AH0KU7Rb5fgBUa1yzz2+DaQ
         hBEdQSA2a7W8yemv4q9CJgb7vH08I7tKUGw2S8EBGND+plVsiUGo3ay/jNTuo42Xwbf9
         DKoG7L80L1iTvOd+eecaSXKuufE3tc6nqao99F+0FHG6ab3cTOUQX0ZPJmvsiKPYe9Gb
         GTbw==
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=sZ2lc4ODAfIKlu23mUsVtS29kErwUbVbfljD8tISSnQ=;
        b=ALP94iiOip+JbJ+AAQJEKlEUhZHe3/hCMOeX6gV3fjgHYPoEISXnH2KsKhPBIllFC1
         Zhk3ihVQ5rRu1GTVH0JhK+Bufe+LMjl+wFxjIuwRcgrUn6MfQOxFt1Hf7oYYWdmATzyn
         +0snSoRUXsfNme4e69+FD02KlNUJxN70uMdh3QxDPTphd2VCcFPs3x6S2/angHla1vfr
         nkNNfHby6z7meHbCU+vAn+5CtJLIcCAdk7RPYT75iuzHtZSwOIyfs3ntCayK0w4Uug64
         lYTruiRF7IpnC3tsr3g/jBuKYdjnVhDpTuT4fO8mgZCPK2xhhNjMkXFQcjmZIWU2NaJQ
         1yug==
X-Gm-Message-State: AKGB3mJWwGsHDHXqQV+UClPYg7t87LOer4mQtWnud0Jp9kb0sR4DUHr1
	YVHFLvY9H9evM243O6xGiNsKwA==
X-Google-Smtp-Source: AGs4zMb6Yyz9Vps7443fKX7kjPepYvPLqA4j66X9a3OFBLSGanqccg7pE//Tu/hUGhJEIiMuA79EJQ==
X-Received: by 10.237.62.237 with SMTP id o42mr10952235qtf.1.1512368899525;
        Sun, 03 Dec 2017 22:28:19 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.200.3.34 with SMTP id q34ls3462368qtg.10.gmail; Sun, 03 Dec
 2017 22:28:18 -0800 (PST)
X-Received: by 10.200.42.122 with SMTP id l55mr17908526qtl.66.1512368898527;
        Sun, 03 Dec 2017 22:28:18 -0800 (PST)
ARC-Seal: i=1; a=rsa-sha256; t=1512368898; cv=none;
        d=google.com; s=arc-20160816;
        b=VgF7HmoEZJYYMOUEzctFr3QjWlfESrP0tS+2FL2QTdWYtEvOt+yOdAnvdmwJiJBWcE
         3iZ7BMQOubMX4ZGYyhm9ZugV28uO4ZThc7MiNvJxI5YLZQtF+BtR0rBqs1jg+EmbdlJH
         THpjSY3vIIDsdXlnfgAoGu6AfaDZ86wAI3Bj8vNpojvWB+PG1BPw33BaBO+T43w+RRFM
         SfmyWac661sYoPuv38FGk/a/OmJcKd/Jjw9bbJgQZ4xP12RYutUdFo11sSOQ13EAgE4q
         +UDcvCfagsUXuLZkfRYtspAtbG7FTZWc2L4D3iAdSZheUmXK21Mui0VGqQcK+UQcW5N2
         eVVw==
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=9XEZE3FPUFeEwCIPXlDGFm2JKi2RmBIcKRoiaXbxdWw=;
        b=k+OqJNqaLvp42YrlMMO3jOAYjFQ3d05/Ezqm31cBYodof8vocAhMP9GaOH9oDwyQtn
         lYAkDm45062M7wub2LrwX7KY+oIWKWtfuLPu4OSuJiQyp+MpJoz/wQDI8GjkJtRCCy4I
         WnV168q8x9tBUOiTzDDxQxa+AgOgkYAJtxuRZFPSlM2k998XhYgEBWelWZHQRQse9vy3
         YBw0drdfFLTqYHckphybenJF2WexLG3NGSN+q89X5YSij0jFYPpmGDglAqm8VNWj8xqQ
         T5sHzMru0TV88BPCnMVJ3YAnyZ9z4+ITKaQSaF6tcZQmab5IZ1mamVg03KnZ869k7gvA
         SWIA==
ARC-Authentication-Results: i=1; mx.google.com;
       spf=pass (google.com: domain of thiago@macieira.org designates 209.222.10.136 as permitted sender) smtp.mailfrom=thiago@macieira.org
Original-Received: from smtp.macieira.info (arvernien.macieira.info. [209.222.10.136])
        by mx.google.com with ESMTPS id q190si4480869qkf.453.2017.12.03.22.28.18
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Sun, 03 Dec 2017 22:28:18 -0800 (PST)
Received-SPF: pass (google.com: domain of thiago@macieira.org designates 209.222.10.136 as permitted sender) client-ip=209.222.10.136;
Original-Received: from tjmaciei-mobl1.localnet (fmdmzpr04-ext.fm.intel.com [192.55.54.39])
	by smtp.macieira.info (Postfix) with ESMTPSA id 4969B3416
	for <std-proposals@isocpp.org>; Sun,  3 Dec 2017 22:28:17 -0800 (PST)
In-Reply-To: <CAHSYqdYGp2CzV5NgCwsrD34A1eEv50-vMNXqUv3B7E=QmHqbCw@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 209.222.10.136 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:35726
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/35726>

On Sunday, 3 December 2017 22:19:08 PST Hyman Rosen wrote:
> On Mon, Dec 4, 2017 at 12:31 AM, Thiago Macieira <thiago@macieira.org>
> 
> wrote:
> > Let's try this one:
> > extern const int v;
> > const int v = 0;
> > void f() { if (v) foo(); else bar(); }
> > 
> > Should the compiler remove the test for v and make an unconditional call
> > to
> > foo()?
> 
> Yes.

Why? See that "extern" on the line above? It means the variable v exists in 
memory somewhere. Since that's the case, I can mremap() the page where it 
exists and change its value from 0 to non-zero.

According to you, the compiler should obey the programmer blindly so long as 
something is possible in hardware. This is.

> This is a trick question.
> 
> No, actually it's not.
> 
> If you answer "yes", then you're being specious. You're fine with some
> > optimisations but not others.  if you answer "no", you're being crazy.
> 
> As I have said over and over, optimization based on propagating values along
> code paths and determining that certain relations must hold is perfectly
> fine.  The
> thing that is wrong is assuming that undefined behavior does not happen and
> using
> that assumption to eliminate code where the compiler sees undefined behavior
> must occur.

Do you want to revise that statement after my hack above?

> > Optimisation must not change the meaning of the code, and the meaning of
> > that
> > comparison is an always false.
> 
> Wrong.  a + 1 < a can be true only is signed overflow occurs.  

It's always false because we said it is. Therefore it is.

If you change the rules, then the results change. But the rules have not 
changed.

> > The compiler should believe the programmer and
> > understand that the comparison was intended to always be false.
> 
> There was a real programmer who wrote that code.  

I think, therefore I am real. I wrote some code that the compiler concluded 
was a signed integer comparison to itself. I know it couldn't overflow. The 
compiler believed me.

-- 
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/2686086.MHsyEc3O6d%40tjmaciei-mobl1.

.
