Assume an implementation with 2 extended integer types as follows :
- INT1 is signed , has 23 value bits and no corresponding unsigned type.
- UINT1 is unsigned , has 40 value bits and no corresponding signed type.
- Both have rank greater than int .
- The rank of UINT1 is smaller than the rank of INT1 .
The last stipulation is perverse but I don't see anything in "6.3.1.1 Boolean, characters, and integers" which forbids it.
With the above , if you have an addition where one operand is of type INT1 and the other of type UINT1 then none of the possibilities (rules) in "6.3.1.8 Usual arithmetic conversions" after the part "Otherwise, the integer
promotions are performed on both operands. Then the following rules are applied to the promoted operands:" is applicable.
Assume an implementation with 2 extended integer types as follows :
- INT1 is signed , has 23 value bits and no corresponding unsigned type.
- UINT1 is unsigned , has 40 value bits and no corresponding signed type.
- Both have rank greater than int .
- The rank of UINT1 is smaller than the rank of INT1 .
The last stipulation is perverse but I don't see anything in "6.3.1.1 Boolean, characters, and integers" which forbids it.
On 5/29/20 9:55 PM, Spiros Bousbouras wrote:
Assume an implementation with 2 extended integer types as follows :
I suspect that you don't mean the following type names to be interpreted literally, but it would have been better for you to choose identifiers
for those types which are reserved to the implementation, such as
__int24_t and __uint40_t.
- INT1 is signed , has 23 value bits and no corresponding unsigned type.
"The standard and extended signed integer types are collectively called signed integer types." (6.2.5p4).
"For each of the signed integer types, there is a corresponding (but different) unsigned integer type ..." (6.2.5p6).
- UINT1 is unsigned , has 40 value bits and no corresponding signed type.
That, however, is permitted, since 6.2.5p6 is asymmetrical.
On 5/29/20 9:55 PM, Spiros Bousbouras wrote:
Assume an implementation with 2 extended integer types as follows :
I suspect that you don't mean the following type names to be interpreted literally, but it would have been better for you to choose identifiers
for those types which are reserved to the implementation, such as
__int24_t and __uint40_t.
- INT1 is signed , has 23 value bits and no corresponding unsigned type.
"The standard and extended signed integer types are collectively called signed integer types." (6.2.5p4).
"For each of the signed integer types, there is a corresponding (but different) unsigned integer type ..." (6.2.5p6).
- UINT1 is unsigned , has 40 value bits and no corresponding signed type.
That, however, is permitted, since 6.2.5p6 is asymmetrical.
- Both have rank greater than int .
- The rank of UINT1 is smaller than the rank of INT1 .
The last stipulation is perverse but I don't see anything in "6.3.1.1
Boolean, characters, and integers" which forbids it.
I believe you are correct about that, and I agree that it's a problem -
but not because of what you wrote below:
With the above , if you have an addition where one operand is of type INT1 >> and the other of type UINT1 then none of the possibilities (rules) in
"6.3.1.8 Usual arithmetic conversions" after the part "Otherwise, the integer
promotions are performed on both operands. Then the following rules are
applied to the promoted operands:" is applicable.
Since there is required to be a corresponding unsigned integer type, the
last rule would apply:
"Otherwise, both operands are converted to the unsigned integer type corresponding to the type of the operand with signed integer type."
That rule specifies a conversion that would loose information from the
signed value, which is what I consider to be bad about the fact that
such an implementation is allowed.
James Kuyper <jameskuyper@alumni.caltech.edu> writes:...
On 5/29/20 9:55 PM, Spiros Bousbouras wrote:
- UINT1 is unsigned , has 40 value bits and no corresponding signed type.
That, however, is permitted, since 6.2.5p6 is asymmetrical.
No, it isn't. Read 6.2.5 p6 more carefully. ...
On Saturday, May 30, 2020 at 5:18:39 AM UTC-4, Tim Rentsch wrote:
James Kuyper <jameskuyper@alumni.caltech.edu> writes:
On 5/29/20 9:55 PM, Spiros Bousbouras wrote:
...
- UINT1 is unsigned , has 40 value bits and no corresponding signed type. >>>That, however, is permitted, since 6.2.5p6 is asymmetrical.
No, it isn't. Read 6.2.5 p6 more carefully. ...
You're right. While the part that I quoted is asymmetrical, the last
part of that clause says:
"The type _Bool and the unsigned integer types that correspond to the standard signed integer types are the _standard unsigned integer types_.
The unsigned integer types that correspond to the extended signed
integer types are the _extended unsigned integer types_. The standard
and extended unsigned integer types are collectively called _unsigned
integer types_."
I've used '_' to mark the phrases that are in italics, indicating that
the sentences containing those phrases constitute the official
definitions of those terms. Therefore, you are correct - UINT1 wouldn't qualify as an unsigned integer type, because it doesn't correspond to
any signed integer type.
I'd much prefer, in the future, if you would simply quote the relevant
text, rather than asking me to "Read ... more carefully." Based on
previous experience with you, there's a pretty good chance that I won't recognize the text that you think is relevant, because in my opinion, it isn't relevant, though this particular case is not an example.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 248 |
Nodes: | 16 (2 / 14) |
Uptime: | 41:17:15 |
Calls: | 5,495 |
Calls today: | 3 |
Files: | 11,665 |
Messages: | 5,038,649 |
Posted today: | 2 |