I am not sure if promotion just means converting a data type to a larger data type (for example short
to int
).
Or does promotion means converting a data type to another "compatible" data type, for example converting a short
to an int
, which will keep the same bit pattern (the extra space will be filled with zeros). And is conversion means converting something like an int
to a float
, which will create a completely different bit pattern?
There are two things that are called promotions: integral promotions and floating point promotions. Integral promotion refers to integral types (including bitfields and enum
s) being converted to "larger" integral types and floating point promotion is specifically just float
to double
.
Both types of promotions are subsets of a wider range of conversions.
char
-> int
: integral promotionfloat
-> double
: floating point promotionint
-> char
: [narrowing] conversion (not a promotion)int
-> float
: conversionconst char*
-> std::string
: conversionFoo
-> Bar
: possibly undefined conversion?