GCC Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
gcc/analyzer

Analyzer supports exception subclass matching.

GCC analyzer now correctly identifies caught exceptions that are derived classes of the caught type.

The static analyzer’s exception handling has been improved to correctly identify when a thrown exception, which is a derived class, is caught by a handler expecting a base class. This is achieved by introducing a new exception_matches_type_p langhook, implemented by the C++ frontend using can_convert_eh. This change ensures more accurate static analysis of exception flows.

In Details

The GCC static analyzer's exception_matches_type_p function previously only matched identical exception and handler types. This commit introduces a language hook for this functionality, allowing frontends like C++ to implement correct subclass matching via can_convert_eh. This ensures the analyzer respects language-specific exception inheritance rules, improving its ability to track potential exception catches.

For Context
analyzer
GCC's static analysis engine that checks code for potential errors and undefined behavior without executing it.
langhook
An interface or callback mechanism allowing different language frontends (like C++ or C) to provide frontend-specific behavior to core GCC components.
exception_matches_type_p
A language hook that determines if an exception of a given type would be caught by a handler for another given type, considering language rules like inheritance.
can_convert_eh
A C++ frontend function that checks if an exception of one type can be converted to another, relevant for determining if a handler catches a derived exception.
C++ frontend
The part of the GCC compiler responsible for parsing and processing C++ source code.
Filed Under: analyzerexception handlingc++static analysis