220 39310 <c3b7a4c0-b76a-4b23-817c-abd445c270c1@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: inkwizytoryankes@gmail.com
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Alternative proposal for mapping P0709
 Deterministic Exceptions into C
Date: Mon, 23 Jul 2018 10:30:12 -0700 (PDT)
Lines: 99
Approved: news@gmane.org
Message-ID: <c3b7a4c0-b76a-4b23-817c-abd445c270c1@isocpp.org>
References: <6a65c934-5d2a-4e75-b88d-9eaaee338bd3@isocpp.org>
 <87240a3d-623f-4f7f-8e7c-fa8c9482fa72@isocpp.org>
 <5a449c86-b0f4-4b07-b5d6-21b7adbfd63b@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_8519_1714243726.1532367012993"
X-Trace: blaine.gmane.org 1532366890 20520 195.159.176.226 (23 Jul 2018 17:28:10 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Mon, 23 Jul 2018 17:28:10 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBDDLTAGNTIBBBJNB3DNAKGQEOM3DPKY@isocpp.org Mon Jul 23 19:28:06 2018
Return-path: <std-proposals+bncBDDLTAGNTIBBBJNB3DNAKGQEOM3DPKY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-yw0-f200.google.com ([209.85.161.200])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBDDLTAGNTIBBBJNB3DNAKGQEOM3DPKY@isocpp.org>)
	id 1fhect-0005CW-Pi
	for gclcip-std-proposals@m.gmane.org; Mon, 23 Jul 2018 19:28:03 +0200
Original-Received: by mail-yw0-f200.google.com with SMTP id 2-v6sf647810ywn.13
        for <gclcip-std-proposals@m.gmane.org>; Mon, 23 Jul 2018 10:30:15 -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=TKGlER9TMD+fQCLq09kUqV+pBrqDgPz0mg9o6KLC1UE=;
        b=I5r+4To5CjFHhl+mDmfkxbaKXwABu1jKVQ90jlbSfzujq0767BMpomwmD8tEkqjJ5u
         aOSC2dL6+qIR7p/cJqb3nvPrJZFHtTlbimdbRa/EGDPr+1DecPNbhblhkGfXcwV2kms4
         NinEs/LkiFZ0edHUrANxq+0xAT/T42rA7U3SKY33jZN0625WjGRiELs6o09Y4OUAcC0o
         hv2MZdAZaeBTos/zjdMFlBWIk+tDjYB3eu+oCJj5xZAiX/sJOwdywikinie0g96+1yff
         iv0Kj7gvfRVra7xOsaorq9mQzHYoZZwjDfgb47sa85fp8ZcGrQubiuEXNHIaLvB0Pj/t
         2Vpg==
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=TKGlER9TMD+fQCLq09kUqV+pBrqDgPz0mg9o6KLC1UE=;
        b=koF6pGHKkG9E82wTHTgaLPOpGmioWUDNsBEOjnPEj8/Lup3tLgKBa6RDbHm948jau8
         TfagBUHTJcfj7RRAwixOsQ47JLf8Go6Smv7ZEptN2XcfBnOx+Uj2sa6rRjgD1fdqisg3
         2CG/rT1AcQGcwoiHRz4B45IxC/cooCSf/SCDfURH6V4aKr2eKRroiMn1xsafMuHMrPeJ
         Oc8C7GVQ+IAnMls9Fs8UHTyjU1rBZ/+b1kEXg4ixKHQKjJLsjEpi52qs768uuRzWQQ5F
         6JcDUnDNKilnCj+sCoYijpN1U9baY3yMpdv5DrG9TJM7bDl7xr7qwAURKpRrOLWnE4hr
         1DSA==
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=TKGlER9TMD+fQCLq09kUqV+pBrqDgPz0mg9o6KLC1UE=;
        b=CXhqRRSJtwX2W+BA/yo67Sf5Np/S/Jm1yKCgGsayELX1oVPYeq9qbzzb184sBs+LMZ
         pwIO1JYpYUvwUdVidYrNZI+71ZaMqqNDzBTRoOSx5mN/iD/xAeaHrLhrW5+hEXVzDeel
         L4HRI7DhBpD05aF6V1m8xIUzxBgokkUzLZRfarij1qaSoaoNRIeUTZl2qRUCu9wgAPzR
         t2f84p7ewjWC1i7aEmp4A5qDFvthn0twBmX42bnJBt4r9kJ3rjxTldah/smKcRDtvUf4
         gLutahVxBmLzkv8ulq7+b3OjiaGt1IBZiRV0KTDK4YLBGSJg6JIfhgfGkoqxU46p0v90
         ysCw==
X-Gm-Message-State: AOUpUlG7v6Cdpg/kNBTMkdwLihIpMo6YtOPqK9gN+iElFc0hP0hayLX8
	5rRAfatLNFHhnGWKa5Rq4bIjsw==
X-Google-Smtp-Source: AAOMgpf60oisGMmQaxdWPTm0iSNGNOg1iUn9Nd+jPTxyUK18haSb3NHOIIE+Fp19KyHeAL1o+SQrRQ==
X-Received: by 2002:a25:b90a:: with SMTP id x10-v6mr3758202ybj.79.1532367014593;
        Mon, 23 Jul 2018 10:30:14 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 2002:a81:a703:: with SMTP id e3-v6ls1104255ywh.37.gmail; Mon, 23
 Jul 2018 10:30:13 -0700 (PDT)
X-Received: by 2002:a81:78c6:: with SMTP id t189-v6mr265273ywc.7.1532367013679;
        Mon, 23 Jul 2018 10:30:13 -0700 (PDT)
In-Reply-To: <5a449c86-b0f4-4b07-b5d6-21b7adbfd63b@isocpp.org>
X-Original-Sender: inkwizytoryankes@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:39310
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/39310>

------=_Part_8519_1714243726.1532367012993
Content-Type: multipart/alternative; 
	boundary="----=_Part_8520_1785100287.1532367012993"

------=_Part_8520_1785100287.1532367012993
Content-Type: text/plain; charset="UTF-8"



On Monday, July 23, 2018 at 10:11:45 AM UTC+2, Niall Douglas wrote:
>
> Overall, do we really need this 'expected' kind of type to be quite so 
>> constrained and magic, to require an even address etc. etc.
>> In other words, if the type was actually something that was specified as 
>> a 'normal' C/C++ struct without any of those gymnastics and data packing 
>> or require some carry register etc., would the code be that dramatically 
>> worse that we should require such magic or constraints than a regular type 
>> without all the magic and alignment requirements?
>>
>> Not speaking for the above proposal, but in general, it is currently 
> believed that using something like the CPU carry bit ought to be zero 
> overhead on most CPUs, whereas a discriminant stored in the layout would 
> not be zero overhead on more CPUs.
>
> The situation of RISC-V, which has no status register, is a particular 
> unknown. Our current best guess is that either we keep the discriminant in 
> the structure, or we fiddle with the return address e.g. offset it by four. 
> There are no good options on that architecture.
>
> Niall 
>

On RISC-V then cost will be same to `bool foo(void* ret)`. This will be 
still "zero overhead", simply for other architectures it will be "negative 
overhead" compared to equivalent manual checks in code.

Another way could be use RVO-like calling convention. Place for return 
union with discriminant will be pass as one pointer to function, this 
storage could even be reused by next function if it return same error type.

-- 
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/c3b7a4c0-b76a-4b23-817c-abd445c270c1%40isocpp.org.

------=_Part_8520_1785100287.1532367012993
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>On Monday, July 23, 2018 at 10:11:45 AM UTC+2, Nia=
ll Douglas wrote:<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"><blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;b=
order-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div>Overall, =
do we really need this &#39;expected&#39; kind of type to be quite so const=
rained and magic,=C2=A0to require an even address etc. etc.</div><div>In ot=
her words, if the type was actually something that was specified=C2=A0as a =
&#39;normal&#39; C/C++ struct without any of those gymnastics and data pack=
ing or=C2=A0require some carry register etc., would the code be that dramat=
ically worse that we should require such magic or constraints than a regula=
r type without all the magic and alignment requirements?</div><div><br></di=
v></div></blockquote><div>Not speaking for the above proposal, but in gener=
al, it is currently believed that using something like the CPU carry bit ou=
ght to be zero overhead on most CPUs, whereas a discriminant stored in the =
layout would not be zero overhead on more CPUs.</div><div><br></div><div>Th=
e situation of RISC-V, which has no status register, is a particular unknow=
n. Our current best guess is that either we keep the discriminant in the st=
ructure, or we fiddle with the return address e.g. offset it by four. There=
 are no good options on that architecture.</div><div><br></div><div>Niall=
=C2=A0</div></div></blockquote><div><br></div><div>On RISC-V then cost will=
 be same to `bool foo(void* ret)`. This will be still &quot;zero overhead&q=
uot;, simply for other architectures it will be &quot;negative overhead&quo=
t; compared to equivalent manual checks in code.</div><div><br></div><div>A=
nother way could be use RVO-like calling convention. Place for return union=
 with discriminant will be pass as one pointer to function, this storage co=
uld even be reused by next function if it return same error type.</div><div=
><br></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/c3b7a4c0-b76a-4b23-817c-abd445c270c1%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/c3b7a4c0-b76a-4b23-817c-abd445c270c1=
%40isocpp.org</a>.<br />

------=_Part_8520_1785100287.1532367012993--

------=_Part_8519_1714243726.1532367012993--

.
