Re: D1095R0/N2xxx draft 4: Zero overhead deterministic failure - A unified mechanism for C and C++

2018-08-12 Thread Niall Douglas
> I think your paper's example should NOT use abs(), but instead some
> other function (whether you merely rename your existing example to
> 'myabs', or pick a different function which DOES have well-defined errno
> semantics right now), precisely because abs() does NOT currently have
> well-defined errno semantics and it is controversial on whether such
> semantics should be given to it.

If that's literally the only feedback, then that's no problem to change.

Niall



Re: D1095R0/N2xxx draft 4: Zero overhead deterministic failure - A unified mechanism for C and C++

2018-08-09 Thread Eric Blake

On 08/08/2018 07:19 PM, Eric Blake wrote:

We've just had a discussion on whether standard-compliant abs() (which 
is currently undefined on INT_MIN) should be permitted and/or required 
to have well-defined behavior


I failed to provide a summary to my thoughts:

I think your paper's example should NOT use abs(), but instead some 
other function (whether you merely rename your existing example to 
'myabs', or pick a different function which DOES have well-defined errno 
semantics right now), precisely because abs() does NOT currently have 
well-defined errno semantics and it is controversial on whether such 
semantics should be given to it.


--
Eric Blake, Principal Software Engineer
Red Hat, Inc.   +1-919-301-3266
Virtualization:  qemu.org | libvirt.org



Re: D1095R0/N2xxx draft 4: Zero overhead deterministic failure - A unified mechanism for C and C++

2018-08-09 Thread Eric Blake

On 08/08/2018 05:24 PM, Niall Douglas wrote:


https://docs.google.com/viewer?a=v=forums=MTEwODAzNzI2MjM1OTc0MjE3MjkBMDIyMjg0NDY2NTc4NzYyMDQzODYBX1RlYjRCNjREQUFKATAuMQFpc29jcHAub3JnAXYy=0




Comments are welcome, particularly on how best to offer POSIX functions
in a form both binary compatible with old code, and which calls the
_Fails(errno) form in newly compiled code.


An initial comment in regards to the example on page 5:

1 int abs(int x)
2 {
3   if(x == INT_MIN)
4   {
5 errno = ERANGE;
6 return 0;
7   }
8   return (x < 0) ? -x : x;
9 }

We've just had a discussion on whether standard-compliant abs() (which 
is currently undefined on INT_MIN) should be permitted and/or required 
to have well-defined behavior (either in the one direction of returning 
INT_MIN, as that is the fewest assembly instructions on typical 
hardware, or in the direction of adding errno handling, as you have done 
here).  The verdict is not final (I wish I could point you to mailing 
list archives, but https://www.opengroup.org/austin/mailarchives/ points 
to gmane, which is no longer functional, and I don't know of any other 
web archival visiting the Austin list).  But so far, a rough consensus 
from the discussion on bug http://austingroupbugs.net/view.php?id=1108 
and http://austingroupbugs.net/view.php?id=1197 is that integral 
functions, like abs(), should NOT signal a range error for performance 
reason (or that setting errno to ERANGE should be a feature of 
floating-point math, not integer math), and that the wording in 1108 
will be once again relaxed to leave behavior of abs(INT_MIN) undefined, 
rather than well-defined (any specific implementation can, of course, 
define behavior as an extension to POSIX).


--
Eric Blake, Principal Software Engineer
Red Hat, Inc.   +1-919-301-3266
Virtualization:  qemu.org | libvirt.org