逗号在变量列表中是否是序列点? [英] Is the comma in a variable list a sequence point?

查看:123
本文介绍了逗号在变量列表中是否是序列点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在下面的代码类型中,每个变量结构之间是否有一个序列点,或者结果是否未定义?

In the following type of code is there a sequence point between each variable construction, or is the result undefined?

int a = 0;
int b = a++, c = a++;

我在标准中找不到特定的序列点引用。这是否意味着它是未定义的,还是只是我在我的搜索失败?表达式的完成是一个序列点,但上述初始化是否也计数?

I wasn't able to find in the standard a specific reference to a sequence point here. Does that mean it is undefined, or just that I failed in my search? The completion of an expression is a sequence point, but does the above initialization also count?

推荐答案

因为 8 [dcl.decl] / 3


声明中的每个init声明

Each init-declarator in a declaration is analyzed separately as if it was in a declaration by itself.

这是在脚注中另外解释为

Which is even additionally explained in a footnote as


一个带有几个声明符的声明通常相当于对应的声明序列,每个声明都有一个
声明符。也就是

A declaration with several declarators is usually equivalent to the corresponding sequence of declarations each with a single declarator. That is

T D1, D2, ... Dn;

通常等价于

T D1; T D2; ... T Dn;


这篇关于逗号在变量列表中是否是序列点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆