简单的解析问题

发布于 2024-10-07 15:55:42 字数 425 浏览 0 评论 0原文

可能的重复:
谁能解释一下这些未定义的行为(i = i++ + ++i , i = i++ 等...)
未定义的行为和序列点(C++ 常见问题解答条目)

在C和C++中如何表达x++++y 已解析?作为 x++ ++ +y 或作为 x++ + ++y ?

Possible Duplicate:
Could anyone explain these undefined behaviors (i = i++ + ++i , i = i++, etc…)
Undefined Behavior and Sequence Points (C++ FAQ entry)

In C and C++ how is the expression x+++++y parsed? As x++ ++ +y or as x++ + ++y ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夜光 2024-10-14 15:55:42

x+++++y 被解析为 x ++ ++ + y 而不是 x ++ + ++ y。根据 Maximal Munch 原则,“分词器应该不断从源文件中读取字符,直到添加多一个字符会导致当前标记不再有意义”

x++ ++ +y 不应编译(在 C 和 C++ 中),因为后递增运算符 ++ 需要一个lvalue 作为参数并返回一个rvalue

x+++++y is parsed as x ++ ++ + y and not as x ++ + ++ y. According to Maximal Munch principle "the tokenizer should keep reading characters from the source file until adding one more character causes the current token to stop making sense"

x++ ++ +y should not compile(In C and C++) because the post-increment operator ++ requires an lvalue as an argument and returns an rvalue.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文