Skip to content

fix: minor correctness, doc, and include nits#1366

Merged
henryiii merged 1 commit into
mainfrom
fix/minor-nits
Jul 1, 2026
Merged

fix: minor correctness, doc, and include nits#1366
henryiii merged 1 commit into
mainfrom
fix/minor-nits

Conversation

@henryiii

Copy link
Copy Markdown
Collaborator

🤖 AI text below 🤖

Summary

  • FileOnDefaultPath UB fix: Guard default_path.back() call so constructing with an empty default_path no longer invokes undefined behaviour; added regression tests in tests/HelpersTest.cpp.
  • PositiveNumber subnormal fix: Replace std::numeric_limits<double>::min (smallest normal positive) with denorm_min so subnormal-positive values like 5e-324 are correctly accepted; added regression test.
  • overflowCheck return type: Both signed and unsigned overloads declared T as return type but actually returned a bool comparison; changed to bool. checked_multiply callers are unaffected (they test the result as bool).
  • Doc/comment fixes:
    • ExecPermissions comment corrected from "available for write" to "available for execute".
    • AsSizeValue example "1 b" => 100 corrected to => 1.
    • App class doc reworded to remove references to nonexistent Program() and .start.
    • App::required() doc fixed (was copy-paste of allow_extras doc).
  • Unused include: Removed <algorithm> from include/CLI/impl/Argv_inl.hpp (confirmed unused; needed headers <memory>, <stdexcept>, <string> remain).

Test plan

  • All 24 existing CTest tests pass (100% tests passed, 0 tests failed out of 24)
  • prek -a --quiet passes cleanly (clang-format auto-fixes incorporated)
  • New test Validators: FilePathModifier covers empty-path construction without crash
  • New test Validators: PositiveValidator covers subnormal-positive acceptance

Part of #1357

- Guard `FileOnDefaultPath` lambda against UB when `default_path` is empty
  (skip `back()` call on empty string)
- Use `denorm_min` instead of `min` for `PositiveNumber` so subnormal
  positives are accepted
- Fix `overflowCheck` return type from `T` to `bool` in both overloads
- Fix `ExecPermissions` comment ("write" -> "execute")
- Fix `AsSizeValue` doc example ("1 b" => 100 -> => 1)
- Reword stale `App` class comment (removed nonexistent `Program()` / `.start`)
- Fix copy-pasted doc on `App::required()` to describe what it actually does
- Remove unused `<algorithm>` include from `impl/Argv_inl.hpp`
- Add regression tests for empty-path `FileOnDefaultPath` and subnormal
  positive values in `PositiveNumber`

Assisted-by: ClaudeCode:claude-sonnet-4-6
@henryiii henryiii marked this pull request as ready for review June 15, 2026 15:00
@henryiii henryiii merged commit 078c741 into main Jul 1, 2026
70 checks passed
@henryiii henryiii deleted the fix/minor-nits branch July 1, 2026 20:15
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.

1 participant