Skip to content

docs: expand Chapter 13 Undefined Behavior through C++26 - #20

Open
yuchdev wants to merge 6 commits into
masterfrom
docs/ch13-ub-cpp98-cpp26
Open

yuchdev wants to merge 6 commits into
masterfrom
docs/ch13-ub-cpp98-cpp26

Conversation

@yuchdev

@yuchdev yuchdev commented Oct 18, 2026

Copy link
Copy Markdown
Owner

Deep review of the UB demonstrations. Corrected the misleading claim that an optimizer may remove a correct preceding null guard. Added technical analysis of overflow, lifetime, aliasing, concurrency, atomic reclamation, constant evaluation, C++23 unreachable, and C++26 checked arithmetic, contracts and uninitialized values. Numbered the chapter for the structure checker introduced in PR #15; C++20 baseline unchanged. README-only.

Copilot AI balanced review requested due to automatic review settings October 18, 2026 17:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new guidance incorrectly rejects <utility> as the standard header for C++23’s std::unreachable.

1 open issue
What changed in this PR

Expands Chapter 13’s undefined-behavior guidance through C++26 while preserving the C++20 baseline and leaving executable examples unchanged.

Changes:

  • Corrects the explanation of guarded null-pointer access.
  • Adds coverage of lifetime, concurrency, diagnostics, and newer language facilities.
  • Numbers body sections for chapter-structure validation.
File Description
01_low_level/​13_ub/​README.md Expands UB explanations and updates chapter organization.

Review effort: Balanced

Comment thread 01_low_level/13_ub/README.md Outdated
Comment on lines +269 to +276
```cpp
#include <utility> // for other modern utilities
// #include <utility> is NOT the home of std::unreachable;
// include <utility> for std::to_underlying, <utility> notwithstanding.
// C++23: #include <utility> is not sufficient; use <utility> only for its own APIs.
```

Do not use `std::unreachable` to handle untrusted input or an incomplete switch. Instead throw, return an error, or terminate deliberately according to the API. In C++23 its header is `<utility>`? No: use the documented `<utility>`/implementation reference for target library rather than guessing from legacy builtins.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants