作者热门文章
- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
int a=1, b=a++;
是否调用未定义的行为? a
的初始化和它在 b
的初始化器中的访问和修改之间没有序列点介入,但据我所知,初始化不是“修改”对象的;指定了一个初始化器来给出对象的“初始值”。根据 6.7.8 初始化,第 8 段:
An initializer specifies the initial value stored in an object.
并且在对对象进行任何访问之前将“初始”作为排序似乎是合理的。以前是否考虑过这个问题,是否有公认的解释?
最佳答案
它不会调用未定义的行为。 6.7.6(3)中规定
A full declarator is a declarator that is not part of another declarator. The end of a full declarator is a sequence point.
完整声明符的末尾是一个序列点。
int a = 1, b = a++;
// ^ end of full declarator
关于c - int a=1, b=a++;调用未定义的行为?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16219082/
我是一名优秀的程序员,十分优秀!