Skip to content

考虑介绍 C++26 起的错误行为 #76

@frederick-vs-ja

Description

@frederick-vs-ja

cppguidebook/docs/undef.md

Lines 585 to 599 in 8119e85

### 不能读取未初始化的变量
```cpp
int i;
cout << i; // 错!
int i = 0;
cout << i; // 可以,会读到 0
int arr[10];
cout << arr[0]; // 错!
int arr[10] = {};
cout << arr[0]; // 可以,会读到 0
```

这里的错误操作在 C++26 起不再导致未定义行为而是导致(良定义的)错误行为,见 P2795R5

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions