gpt4 book ai didi

c - C 中潜在的未定义行为

转载 作者:太空宇宙 更新时间:2023-11-04 00:48:30 25 4
gpt4 key购买 nike

我需要知道以下代码是否可能是未定义的行为(我很确定它是):

int main(){
int z=53;
z=z<<=3;
return 0;
}

这是类测试中的一道题。我告诉我的老师我认为是UB,但我的老师不相信我。

最佳答案

这是未定义的。引用 N1256,C99 草案,第 6.5/2 条(强调我的):

Between the previous and next sequence point an object shall have its stored value modified at most once by the evaluation of an expression. 72) Furthermore, the prior value shall be read only to determine the value to be stored. 73)

关于c - C 中潜在的未定义行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28032959/

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