Repository navigation
Conversation
…mization misconception
Contributor
There was a problem hiding this comment.
🟡 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 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

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.