Landing: 2f72dcc5e6cf
Project / Subsystem
gcc / analyzer
Date
2026-08-16
Author
Egas Ribeiro
Commit
2f72dcc5e6cf444a46ce48364af98adf29d3f722
Source
github
Perf win
No
Breaking
No
All attributes
- project
- gcc
- subsystem
- analyzer
- patch_id
- —
- commit_hash
- 2f72dcc5e6cf444a46ce48364af98adf29d3f722
- source_type
- github
- headline
- Add support for analyzing C++ dynamic_cast calls
- tldr
- The GCC analyzer now understands C++ `dynamic_cast` to detect bugs like dereferencing null pointers after failed casts.
- author
- Egas Ribeiro
- outcome
- committed
- performance_win
- false
- breaking_change
- false
- series_id
- —
- series_parts
- []
- tags
-
- • analyzer
- • c++
- • static analysis
- • type safety
- discussion_id_link
- —
- bugzilla_pr
- —
- date
- 2026-08-16T00:00:00.000Z
The GCC static analyzer has been enhanced to understand C++ dynamic_cast operations, resolving a limitation where results of failed casts were treated as opaque. This new functionality allows the analyzer to statically evaluate dynamic_cast calls, similar to the frontend’s cxx_eval_dynamic_cast, enabling it to detect bugs such as dereferencing a null pointer resulting from a failed cast. It works by traversing BINFOs and calculating offsets without directly using frontend trees.