Landing: 5caef7c4a904
Project / Subsystem
gcc / analyzer
Date
2026-05-20
Author
David Malcolm
Commit
5caef7c4a904a065706ad375691f3b9d9bf525cb
Source
github
Perf win
No
Breaking
No
All attributes
- project
- gcc
- subsystem
- analyzer
- patch_id
- —
- commit_hash
- 5caef7c4a904a065706ad375691f3b9d9bf525cb
- source_type
- github
- headline
- analyzer: Add Pointer Difference Folding
- tldr
- The static analyzer now folds pointer subtraction expressions, allowing it to better handle `std::string::size()` on non-empty strings.
- author
- David Malcolm
- outcome
- committed
- performance_win
- false
- breaking_change
- false
- series_id
- —
- series_parts
- []
- tags
-
- • analyzer
- • static analysis
- • pointer arithmetic
- • optimization
- discussion_id_link
- —
- bugzilla_pr
- —
- date
- 2026-05-20T00:00:00.000Z
The static analyzer can now simplify expressions involving pointer subtraction. Specifically, it can fold (X + Y) - X to Y. This allows -fanalyzer to reason about std::string::size() when called on non-empty strings. This improvement enhances the analyzer’s ability to detect potential issues in code that uses pointer arithmetic.