Is promotion to int required by the C++ standard?

前端 未结 1 1100
情歌与酒
情歌与酒 2021-01-20 15:38

Take the following code fragment.

short int a, b = 30001, c = 30002, d = 30003;
a = b + c - d;

Assume that short int is 16 bits and int is

1条回答
  •  走了就别回头了
    2021-01-20 15:54

    Farther down in 4/5 is:

    These conversions are called integral promotions.

    So when 5/10 says that "integral promotions shall be performed", it means that whichever one of the listed conversions matches (there is only ever one match) is required (in this context).

    The "can be" wording provides a guarantee that these conversions are possible, and does not exclude other conversions from being supported, including identity conversion. But no other conversions carry the name of integral promotion.

    0 讨论(0)
提交回复
热议问题