Visual C++ Integral Promotion

For a project of mine I have developed metafunctions for determining standard promoted integral types (4.5) as well as determining usual arithmetic conversions (5p9) based off of passed template arguments, however, I would now like to also take into account Visual C++'s integral types provided as extensions (I.E. __int64, __int8, etc.). That way, my current project and future projects can use these metafunctions with Visual C++'s type extensions to deduce the type of promotions and operand conversions. In order to be able to accomplish this, I need to know quite a few details concerning how these types are dealt with when used in expressions with different types. In particular, is there any documentation which describes exactly how Visual C++ deals with their extended types in regard to integral promotion and usual arithmetic conversions as described in the selections of the standard which I referenced earlier in this post

Also, are there any plans on supporting extensions simulating typeof or the automatic type-deduction use of auto in future versions of Visual C++ prior to them actually becoming standardized

Thanks in advance.


Answer this question

Visual C++ Integral Promotion

  • Mr. Ahmad

    Hi, Rivorus
    You can download the c99 standard at
    http://www.open-std.org/jtc1/sc22/wg14/www/standards
    and the corresponding c++ standard is at
    http://www.open-std.org/jtc1/sc22/wg21/

  • jlgourmet

    Hmm ... you are right __int8 == char: I agree that this seems like a poor design __int8 definitely says to me integral type, not character type, so I would have expected that __int8 acted like the other integer types not like the weird char, signed char, unsigned char troika in C and C++.

    Actually long long is now in the C++ Standard, or at least in the current working draft for the next official Standard. It was added in October at the last C++ Standards meeting.

    If you send my your e-mail address (send it to joncaves at microsoft dot com) I can send you the paper that describes all the changes that were made to the C++ Standard to incorporate long long. That is probably easier than tyring to reproduce them here: though they are pretty much as you would expect.

  • Alakya

    Thank you very much. Since they were yielding different names from their type-info when using typeid, I assumed they were different types with just the same representation, but after testing some template instantiations, I realize that you are correct. [Edit: After rechecking, this wasn't the case, they do output the same name. I don't know what I was thinking]

    However, upon checking in VC++ 7.1, __int8 is not equivalent to signed char as you describe, but rather, it is equivalent to plain char, though signed __int8 is equivalent to signed char. I believe the more intuitive result would be what you described, having signed __int8 and __int8 both be the same as signed char, with no way to represent plain char using __int8. Having __int8 and signed __int8 being different types seems a little misleading.

    Anyway, there is still the issue that there is no long long in the C++ standard, so that area still needs a small bit of clarification. For instance, usual arithmetic conversions described in 5p9 states that, after appropriate floating point conversions and integral promotions, if either type is unsigned long, the other shall be converted to unsigned long. With the introduction of the unsigned long long type, this certainly is no longer the case (I'd imagine that it would be changed to something along the lines of "if either type is unsigned long long, the other shall be converted to unsigned long long"). This change would also, undoubtedly, affect the remainder of the definition.

    I realize that there is a long long type in C99, so most-likely, the same promotion and usual arithmetic conversions from C99 are applied to Visual C++'s extensions, however, I do not own a copy of the C99 standard. If that is the case, would you be able to provide the adjusted definition of usual arithmetic conversions described in the C99 standard which includes long long

  • ASMerlin

    These types are exactly equivalent to the standard C++ types:

    __int8 == signed char
    __int16 == short
    __int32 == int
    __int64 == long long

    So all the C++ rules on promotion and conversion so behave as expected.

  • Visual C++ Integral Promotion