The following issue has been SUBMITTED. 
====================================================================== 
http://austingroupbugs.net/view.php?id=1197 
====================================================================== 
Reported By:                shware_systems
Assigned To:                
====================================================================== 
Project:                    1003.1(2016)/Issue7+TC2
Issue ID:                   1197
Category:                   System Interfaces
Type:                       Omission
Severity:                   Objection
Priority:                   normal
Status:                     New
Name:                       Mark Ziegast 
Organization:               SHware Systems Dev. 
User Reference:              
Section:                    abs, imaxabs, labs, llabs 
Page Number:                p567 ff 
Line Number:                L19829 ff 
Interp Status:              --- 
Final Accepted Text:         
====================================================================== 
Date Submitted:             2018-07-30 19:19 UTC
Last Modified:              2018-07-30 19:19 UTC
====================================================================== 
Summary:                    Omission from 1108: LONG_MIN must be <= -2147483648
Description: 
In the resolution to 1108, Note 4041, while twos-complement arithmetic is
adequate to describe how the result arises, it overlooks that from a
mathematical and set theory standpoint the operation is also a range error
for the *_MIN values, in that the "correct" result is outside the range
*_MIN to *_MAX. This should be indicated in errno with ERANGE, raise SIGFPE
with Code FPE_INTOVF if not masked, or both. 

Given *_MIN and *_MAX are independent values (with constraints) in both the
C and POSIX <limits.h>, leaving the behavior completely undefined in the C
standard can be considered a defect. It should at least require ERANGE be
set, imo. Assuming a 24-bit width for short, SHORT_MIN could be -1000000
and SHORT_MAX still 32767 and this would be considered conforming, if
pretty asymmetric. This range error would be triggered for each value
between -1000000 and -32768 inclusive, not just -32768.

Note with this potential asymmetry EDOM errors should also be accounted
for, but the appropriate signal code, FPE_INTTRAP or FPE_INTDOM, is missing
from <signal.h>.
Desired Action: 
>From #1108, Change for abs(), other interfaces with similar wording:
On P567 L19829 (abs), replace

    If the result cannot be represented, the behavior is undefined.

with

    <CX>If the result cannot be represented, the result shall be i,
unchanged, and errno shall be set to ERANGE.</CX><XSI> Additionally, the
function shall raise SIGFPE with code FPE_INTOVF after setting
errno.</XSI>


On P567 L19838 (abs), replace

    In two's-complement representation, the absolute value of the negative
integer with largest magnitude {INT_MIN} might not be representable.

with

    <CX>Since POSIX.1 requires a two's complement representation of int,
the absolute value of the negative integer with the largest magnitude
{INT_MIN} is always not representable; the rules of negation in two's
complement arithmetic ensure that {INT_MIN} is returned when the value is
-pow(2,{WORD_BIT}-1) but may produce positive trap representations for
values between {INT_MIN} and negative {INT_MAX} otherwise.</CX>
====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2018-07-30 19:19 shware_systems New Issue                                    
2018-07-30 19:19 shware_systems Name                      => Mark Ziegast    
2018-07-30 19:19 shware_systems Organization              => SHware Systems Dev.
2018-07-30 19:19 shware_systems Section                   => abs, imaxabs, labs,
llabs
2018-07-30 19:19 shware_systems Page Number               => p567 ff         
2018-07-30 19:19 shware_systems Line Number               => L19829 ff       
======================================================================


Reply via email to