ALPINE
> ...то есть в int :)
> результирующим типом "по умолчанию" всегда будет int
Вот видите, вы даже сами сейчас поняли, что не все так очевидно и не нужно на это полагаться:
> P.S.для 64-битных приложений это естественно будет __int64
laMer007
мне просто лень писать каждый раз "тип, являющийся "основным" в данной архитектуре", поэтому пишу int, подразумевая работу с 32-битной x86 архитектурой.
ALPINE
>Какого бы типа ни были операнды, результат выражения будет типа int (4 байта).
Бред полный. интом они становятся при передаче через эллипсис
AndryBlack
> Бред полный. интом они становятся при передаче через эллипсис
Интом они становятся ещё до выполнения операции. Это тут уже обсуждалось.
Для полноты картины приведу цитаты из стандарта
A prvalue of an integer type other than bool, char16_t, char32_t, or wchar_t whose integer conversion rank (4.13) is less than the rank of int can be converted to a prvalue of type int if int can represent all the values of the source type; otherwise, the source prvalue can be converted to a prvalue of type unsigned int.
Every integer type has an integer conversion rank defined as follows: — No two signed integer types other than char and signed char (if char is signed) shall have the same rank, even if they have the same representation. — The rank of a signed integer type shall be greater than the rank of any signed integer type with a smaller size. — 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. — The rank of any unsigned integer type shall equal the rank of the corresponding signed integer type. — The rank of any standard integer type shall be greater than the rank of any extended integer type with the same size.
Many binary operators that expect operands of arithmetic or enumeration type cause conversions and yield result types in a similar way. The purpose is to yield a common type, which is also the type of the result. This pattern is called the usual arithmetic conversions, which are defined as follows: — If either operand is of scoped enumeration type (7.2), no conversions are performed; if the other operand does not have the same type, the expression is ill-formed. — If either operand is of type long double, the other shall be converted to long double. — Otherwise, if either operand is double, the other shall be converted to double. — Otherwise, if either operand is float, the other shall be converted to float. — Otherwise, the integral promotions (4.5) shall be performed on both operands.59 Then the following rules shall be applied to the promoted operands: — If both operands have the same type, no further conversion is needed. — Otherwise, if both operands have signed integer types or both have unsigned integer types, the operand with the type of lesser integer conversion rank shall be converted to the type of the operand with greater rank. — Otherwise, if the operand that has unsigned integer type has rank greater than or equal to the rank of the type of the other operand, the operand with signed integer type shall be converted to the type of the operand with unsigned integer type. — Otherwise, if the type of the operand with signed integer type can represent all of the values of the type of the operand with unsigned integer type, the operand with unsigned integer type shall be converted to the type of the operand with signed integer type. — Otherwise, both operands shall be converted to the unsigned integer type corresponding to the type of the operand with signed integer type.
ud1
и? не вижу здесь разъяснений. Более того, написано вот что:
> ...The purpose is to yield a common type, which is also the type of the result. ...
> ...
> integral promotions (4.5) shall be performed on both operands.59 Then the following
> rules shall be applied to the promoted operands:
> — If both operands have the same type, no further conversion is needed.
> ...
Как будто требуют отсутствия преобразования в случае, если операнды одинакового типа. Запутался я в этом стандарте. А свои утверждения я проверял на живом примере.
Тема в архиве.