T
Tomás Ó hÉilidhe
Here's a hypothetical:
(There's no padding bits in the integer types)
CHAR_BIT == 8
sizeof(short) == 2 (16-Bit)
sizeof(int) == 8 (64-Bit)
Let's say the compiler has its own extra type as an extension, such as
"longshort":
sizeof (longshort) == 4 (it's 32-Bit)
I want to find out whether the Standard requires this extended integer
type, which is smaller than an int, to undergo integer promotion to
become a "signed int". I've been reading the Standard for couple of
minutes but I'm not certain. Here's a relevant excerpt:
"The following may be used in an expression wherever an int or
unsigned int may
be used: An object or expression with an integer type whose integer
conversion rank is less
than or equal to the rank of int and unsigned int."
The rank is established as follows:
"The rank of long long int shall be greater than the rank of long int,
which
shall be greater than the rank of int, which shall be greater than the
rank of short
int, which shall be greater than the rank of signed char."
This doesn't clarify in my head whether "longshort" must undergo
integer promotion to a "signed int" in this case.
Here's another excerpt but I don't believe it gives any clarification:
"The rank of any standard integer type shall be greater than the rank
of any extended
integer type with the same width."
If you changed "with the same width" to "with same or lesser width",
then that would tell me that "longshort" must undergo promotion, but
currently I don't see any requirement for "longshort" to undergo
promotion.
Any thoughts?
(There's no padding bits in the integer types)
CHAR_BIT == 8
sizeof(short) == 2 (16-Bit)
sizeof(int) == 8 (64-Bit)
Let's say the compiler has its own extra type as an extension, such as
"longshort":
sizeof (longshort) == 4 (it's 32-Bit)
I want to find out whether the Standard requires this extended integer
type, which is smaller than an int, to undergo integer promotion to
become a "signed int". I've been reading the Standard for couple of
minutes but I'm not certain. Here's a relevant excerpt:
"The following may be used in an expression wherever an int or
unsigned int may
be used: An object or expression with an integer type whose integer
conversion rank is less
than or equal to the rank of int and unsigned int."
The rank is established as follows:
"The rank of long long int shall be greater than the rank of long int,
which
shall be greater than the rank of int, which shall be greater than the
rank of short
int, which shall be greater than the rank of signed char."
This doesn't clarify in my head whether "longshort" must undergo
integer promotion to a "signed int" in this case.
Here's another excerpt but I don't believe it gives any clarification:
"The rank of any standard integer type shall be greater than the rank
of any extended
integer type with the same width."
If you changed "with the same width" to "with same or lesser width",
then that would tell me that "longshort" must undergo promotion, but
currently I don't see any requirement for "longshort" to undergo
promotion.
Any thoughts?