220 39736 <eba9269f-99e8-4ed5-86ad-c05512e56f9e@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Niall Douglas <nialldouglas14@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: D1095R0/N2xxx draft 4: Zero overhead
 deterministic failure - A unified mechanism for C and C++
Date: Sun, 12 Aug 2018 15:12:40 -0700 (PDT)
Lines: 151
Approved: news@gmane.org
Message-ID: <eba9269f-99e8-4ed5-86ad-c05512e56f9e@isocpp.org>
References: <206ed6c7-67da-43db-8d21-5d2a359b19b0@isocpp.org>
 <05e6c694-3efe-4caa-8557-0edd07bc0c5f@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_1238_129812676.1534111960377"
X-Trace: blaine.gmane.org 1534111838 30362 195.159.176.226 (12 Aug 2018 22:10:38 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Sun, 12 Aug 2018 22:10:38 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBDGKFT5YZADRBWPBYLNQKGQEYKTBFEI@isocpp.org Mon Aug 13 00:10:34 2018
Return-path: <std-proposals+bncBDGKFT5YZADRBWPBYLNQKGQEYKTBFEI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-yw1-f71.google.com ([209.85.161.71])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBDGKFT5YZADRBWPBYLNQKGQEYKTBFEI@isocpp.org>)
	id 1foyZE-0007nE-2k
	for gclcip-std-proposals@m.gmane.org; Mon, 13 Aug 2018 00:10:32 +0200
Original-Received: by mail-yw1-f71.google.com with SMTP id p8-v6sf20689933ywl.14
        for <gclcip-std-proposals@m.gmane.org>; Sun, 12 Aug 2018 15:12:42 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=3Ios/z0Fopgh3btMkOsKJ2K8tJgM51jMiE8t8NK7K/Y=;
        b=TWQZTeZhhVpyqeU94pzBJ01rZFrpLAGBuv4ibklABPFA2XBTF0SDx9E32Sm5kFzvEj
         bXSXbMt/aHluVZNSl2iEM1oXC6gc01qMpQCBG0JhNXqZa6ndU8eV6Da0gNLaMpWyyqiO
         vuH+oDvOBd6S0/LHJnsl8PxmlZt1G+zio21QsnUE9CoWg/QqNzhxaiSKnhXvRQ6xxkq+
         WWLXtQuli5kqHVPRYEpYsTZnBi7dZ26DlSZ0R1kWjVcCWh45UONkgjnar3KPepk1Slqi
         yqDrt2x7yHIjy6SDWHfP4L/vGdVPaTiMX8xtfZQYB6AL2dw94C2dvXhkNupv+uG3NGW0
         3OQg==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=3Ios/z0Fopgh3btMkOsKJ2K8tJgM51jMiE8t8NK7K/Y=;
        b=U3rHQbgHuJvaDoFPGWeFPddoiHNtYuAcnrP+nRXUFtx7QDs0yyxBAxSpyJ9CsBfdE8
         bFQoFvqjfyDaO++DithifeVyx+vUU+fGm1L3JV4m09/qHnbPhu5pJGEG+dBBrwqg1TFw
         04izHUB647RLUBcGs2iS8Dg1XildXAmBPz4S8YyrJzbETxzgBdTpxlEm6iUmnZVnf81d
         ZETwwInjggT1vHswuOxGmDS1D/PFxgx8MV+DcA2V1VDYGDj/t/RwKX6+XkN1PG+JSae6
         t8dbejZzAfgUwQl9ZymIvhZfYucE9IpxG+TKpki9+K/nRNcLxIALBNdORJNUNNfnIPy3
         yiIg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:date:from:to:message-id:in-reply-to:references
         :subject:mime-version:x-original-sender:reply-to:precedence
         :mailing-list:list-id:x-spam-checked-in-group:list-post:list-help
         :list-archive:list-subscribe:list-unsubscribe;
        bh=3Ios/z0Fopgh3btMkOsKJ2K8tJgM51jMiE8t8NK7K/Y=;
        b=F0vYCUSq7YTyHOLjCpT/IFUmZhNzLjf4MzNdnEbvi6zAUIbIoIzO1Nk3C4RpIpXtad
         YsK0Iav+LmL8P9EmpQS2ZR1FSn2jY/84XsV3Tm5NxZBbZGl1InmNLvci5M8grVZ5VRzc
         lAR8PpnkCU9ei4uIXK98U3Imzd7toTHC3XLtPFO/ladWnzvzVufRn0nC1iqEgxDX1Q1S
         P/aVI1WGl+UVy6RBcZeIfrSVjZ1GElLzHztKqiBEZRyj9FYtsFtT7Uw63ocqAqmSgEAx
         jsBSfMNZVV0536/TpGdWmdaup3nOJtZMuJGXQwA0kVuQjWBYUOxktxaL+Upbsk9u4837
         hGEA==
X-Gm-Message-State: AOUpUlHVSd0dxedkCjyjqhwxFn3zXYQ99KIqjItfgvqgb4aBWa/h5DuL
	AF5o2GgxLceVDZYPbItLpIM6og==
X-Google-Smtp-Source: AA+uWPxQ8Ra+eqzl7CCAeQ4stxh4MNRYUxvEIaWGiDvphygUIsG6hjC79EUKKAT8GEjSL5JLlxooxg==
X-Received: by 2002:a81:98cb:: with SMTP id p194-v6mr4664473ywg.9.1534111962290;
        Sun, 12 Aug 2018 15:12:42 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 2002:a81:b1c8:: with SMTP id p191-v6ls2421284ywh.3.gmail; Sun, 12
 Aug 2018 15:12:41 -0700 (PDT)
X-Received: by 2002:a81:5705:: with SMTP id l5-v6mr318313ywb.6.1534111960865;
        Sun, 12 Aug 2018 15:12:40 -0700 (PDT)
In-Reply-To: <05e6c694-3efe-4caa-8557-0edd07bc0c5f@isocpp.org>
X-Original-Sender: nialldouglas14@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:39736
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/39736>

------=_Part_1238_129812676.1534111960377
Content-Type: multipart/alternative; 
	boundary="----=_Part_1239_1512024551.1534111960377"

------=_Part_1239_1512024551.1534111960377
Content-Type: text/plain; charset="UTF-8"


>
>
> 1. The names left and right are not descriptive for their uses. I would 
> prefer expected and unexpected or value and error or something like that.
>

Already changed to _EitherValue() and _EitherError().
 

>    b) The proposed rewrite from a setting of errno + a return statement to 
> a return _Failure() seems scary as the programmer may insert some other 
> code between the errno setting and the return statement.
>

Optimisation already significantly rewrites the programmer's code. 
Everything is "as if" nowadays.
 

>    c) The code that shows the call site for the abs() example is not 
> equivalent to the original as the function may set errno to 0, which is 
> taken as no error by the original code but is still not "positive" by the 
> new means.
>        Upon further inspection it may be that this feature is just not 
> explained clearly enough. I think your intention is that within a 
> _Fails(errno) marked function errno is a local variable. If it is non-zero 
> when a return statement is hit the transformation occurs.
>        This seems to work better than my initial understanding that it is 
> the code pattern of setting errno followed by return that is transformed.
>

Correct, real errno becomes exclusively the compiler's responsibility when 
calling a _FailsWithErrno function.
 

>    d) It is unclear to me what happens if errno is already != 0 when abs() 
> is called. To get backwards compatibility it seems logical that the local 
> errno gets set from the threadlocal errno when abs is entered. If this is 
> the case, please show how the expression:
>        abs(a) + abs(b) is translated (with the problem being that if 
> abs(a) lazily returns an error then abs(b)'s initing of its errno would use 
> a stale value).
>

If you declare your function _FailsWithErrno, it needs to be ported to the 
new system. Specifically, that you can't read errno. Trying to do so fails 
the compile.

For code which calls a _FailsWithErrno function, we know such functions 
never read errno, but they as-if may set it. The compiler optimises 
accordingly.
 

>
> 3. In your last C example it is unclear if the code is the user written 
> code or the compiler rewrite, and in the latter case if the user had a 
> errno = 0 statement at all.
>

I will clarify the wording and spell out why and how statements were elided 
by the compiler due to having no possible side effect.

Niall 

-- 
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/eba9269f-99e8-4ed5-86ad-c05512e56f9e%40isocpp.org.

------=_Part_1239_1512024551.1534111960377
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><blockquote class=3D"gmail_quote" style=3D"margin: 0;margi=
n-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"l=
tr"><div><br></div><div>1. The names left and right are not descriptive for=
 their uses. I would prefer expected and unexpected or value and error or s=
omething like that.</div></div></blockquote><div><br></div><div>Already cha=
nged to _EitherValue() and _EitherError().</div><div>=C2=A0</div><blockquot=
e class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: =
1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><div>=C2=A0 =C2=A0b) Th=
e proposed rewrite from a setting of errno + a return statement to a return=
 _Failure() seems scary as the programmer may insert some other code betwee=
n the errno setting and the return statement.<br></div></div></blockquote><=
div><br></div><div>Optimisation already significantly rewrites the programm=
er&#39;s code. Everything is &quot;as if&quot; nowadays.</div><div>=C2=A0</=
div><blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex=
;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><div></di=
v><div>=C2=A0 =C2=A0c) The code that shows the call site for the abs() exam=
ple is not equivalent to the original as the function may set errno to 0, w=
hich is taken as no error by the original code but is still not &quot;posit=
ive&quot; by the new means.</div><div>=C2=A0 =C2=A0 =C2=A0 =C2=A0Upon furth=
er inspection it may be that this feature is just not explained clearly eno=
ugh. I think your intention is that within a _Fails(errno) marked function =
errno is a local variable. If it is non-zero when a return statement is hit=
 the transformation occurs.</div><div>=C2=A0 =C2=A0 =C2=A0 =C2=A0This seems=
 to work better than my initial understanding that it is the code pattern o=
f setting errno followed by return that is transformed.</div></div></blockq=
uote><div><br></div><div>Correct, real errno becomes exclusively the compil=
er&#39;s responsibility when calling a _FailsWithErrno function.</div><div>=
=C2=A0</div><blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-lef=
t: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><=
div>=C2=A0 =C2=A0d) It is unclear to me what happens if errno is already !=
=3D 0 when abs() is called. To get backwards compatibility it seems logical=
 that the local errno gets set from the threadlocal errno when abs is enter=
ed. If this is the case, please show how the expression:</div><div>=C2=A0 =
=C2=A0 =C2=A0 =C2=A0abs(a) + abs(b) is translated (with the problem being t=
hat if abs(a) lazily returns an error then abs(b)&#39;s initing of its errn=
o would use a stale value).</div></div></blockquote><div><br></div><div>If =
you declare your function _FailsWithErrno, it needs to be ported to the new=
 system. Specifically, that you can&#39;t read errno. Trying to do so fails=
 the compile.</div><div><br></div><div>For code which calls a _FailsWithErr=
no function, we know such functions never read errno, but they as-if may se=
t it. The compiler optimises accordingly.</div><div>=C2=A0</div><blockquote=
 class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1=
px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><div><br></div><div>3. I=
n your last C example it is unclear if the code is the user written code or=
 the compiler rewrite, and in the latter case if the user had a errno =3D 0=
 statement at all.</div></div></blockquote><div><br></div><div>I will clari=
fy the wording and spell out why and how statements were elided by the comp=
iler due to having no possible side effect.</div><div><br></div><div>Niall=
=C2=A0</div></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/eba9269f-99e8-4ed5-86ad-c05512e56f9e%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/eba9269f-99e8-4ed5-86ad-c05512e56f9e=
%40isocpp.org</a>.<br />

------=_Part_1239_1512024551.1534111960377--

------=_Part_1238_129812676.1534111960377--

.
