gpt4 book ai didi

c# - 编译器优化和增量

转载 作者:行者123 更新时间:2023-11-30 21:18:39 25 4
gpt4 key购买 nike

编译器优化会导致这样的代码出现问题吗?具体来说,是否可以回复自动增量以正确的顺序求值?

uint result = (array[i++] << 16) | (array[i++] << 8) | array[i++];

最佳答案

Yes; this is specified .

spec says :

Operands in an expression are evaluated from left to right. For example, in F(i) + G(i++) * H(i), method F is called using the old value of i, then method G is called with the old value of i, and, finally, method H is called with the new value of i. This is separate from and unrelated to operator precedence.

关于c# - 编译器优化和增量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4120301/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com