请注意,这与Operator Precedence.. () and ++,Undefined behavior and sequence points,Why are these constructs using pre and post-increment undefined behavior?以及这里数百个类似的问题无关
不久:标准是否保证关联性?
详细示例:从Wikipedia的关于运算符优先级的文章中,operator*
和operator/
具有相同的优先级,它们是Left-to-right
运算符。这是否意味着,* 标准**保证 *,这:
int res = x / y * z / t;
评价为
int res = ( ( x / y ) * z ) / t;
或者它的实现定义?
如果有保证的话,你能报个价吗?
只是出于好奇,我总是在这些情况下写括号。
准备删除问题,如果有这样的一个。
2条答案
按热度按时间jckbn6z71#
从最新的公开可用的draft
5.6乘法运算符[表达式mul]
1乘法运算符 *、/和%从左到右分组。
所以解析将像这样:
dsekswqp2#
n3337 5.6/1
*乘法运算符 、/和%从左到右分组。
阅读5标准杆。