c++ - 为什么这不会给出编译错误?

标签 c++ c

<分区>

int a = a ;  

根据赋值运算符的规则,它应该从右到左读取该行。在看到 'a' 未声明的编译器后应该给出编译错误。
但是它给出的是垃圾值。请澄清。

最佳答案

§3.3.2/1:

The point of declaration for a name is immediately after its complete declarator (Clause 8) and before its initializer (if any), except as noted below. [ Example:

int x = 12;
{ int x = x; }

Here the second x is initialized with its own (indeterminate) value. —end example ]

关于c++ - 为什么这不会给出编译错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17607888/

相关文章:

c++ - 在 QAbstractTableModel 中使用多个线程之间共享的数据

c++ - 为什么 CLion 可以正确构建和链接 Qt,但不能运行我的可执行文件?

c - 如何从用户空间使用asm/system.h?

c - 换页字符 (FF) 在 MISRA C2 标准中是否有效

c - Android Gradle 插件无法识别 SourceSet 'source'

c++ - 从 C++ 调用 2d std::vector 数组到 Fortran 90 错误

c++ - g++中链接的Preprocessor程序类似于gcc中的cpp程序

c++ - 回文测试器存在逻辑缺陷

c - 测量进程上下文切换

c - 从 void* 到 int 的类型转换,反之亦然