从函数调用顺序点? [英] Sequence point from function call?
本文介绍了从函数调用顺序点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是另一个序列点的问题,而是一个相当简单:
This is yet another sequence-point question, but a rather simple one:
#include <stdio.h>
void f(int p, int) {
printf("p: %d\n", p);
}
int g(int* p) {
*p = 42;
return 0;
}
int main() {
int p = 0;
f(p, g(&p));
return 0;
}
这是不确定的行为?还是调用克(&安培; P)
充当序列点
推荐答案
没有。它不会调用的未定义的行为。这只是的未指定的,因为在该函数参数的计算顺序是标准指定。所以输出可以是 0
或 42
取决于你的编译器决定的评价顺序。
No. It doesn't invoke undefined behavior. It is just unspecified, as the order in which the function arguments are evaluated is unspecified in the Standard. So the output could be 0
or 42
depending on the evaluation order decided by your compiler.
这篇关于从函数调用顺序点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文