GCC Newspaper
JULY 29, 2026
gcc Proposed Sentiment 2 / 10

Gradual 'tree' typing and C++

Reviewers critique a gradual typing proposal for GCC's tree representation, calling it an 'abomination' that makes developers' lives harder.

This discussion follows an exchange about gradual typing in GCC’s internal tree representation. Arsen Arsenović suggested converting checks into fallible conversion functions (e.g., try_as_tree_or_whatever). Jakub Jelinek strongly disagreed, calling it an improvement. Eric Botcazou concurs with Jelinek, expressing dismay that the transition to C++ has led to such ‘abominations’ and arguing it makes compiler development harder.

In the Thread 3 participants
  1. Jakub Jelinek <jakub@redhat.com> reviewer

    Initially rejected the idea outright, stating it's 'the exact opposite' of an improvement.

    “I'm sorry, but this is not an improvement, it is an exact opposite of that.”
  2. Eric Botcazou <ebotcazou@libertysurf.fr> reviewer

    Agrees with Jakub Jelinek, criticizing the proposal as making developers' lives harder and contrary to expectations from C++ adoption.

    “Yes, a very promising attempt at making the life of compiler hackers harder. And we were told that the transition to C++ would not lead to this kind of abominations...”
  3. Arsen Arsenović <aarsenovic@baylibre.com> contributor

    Proposed the change to use explicit fallible conversion functions.

    “Checks-and-uses of TREE_CODEs would also need to become (explicit) fallible conversion functions, i.e. if (TREE_CODE (t) == A) use t; ... becomes: if (auto tA = try_as_tree_or_whatever<A> (t)) use tA;”

Technical Tradeoffs

  • Increased code verbosity and complexity for developers.
  • Potential for compile-time type safety vs. runtime checks.
  • Impact on developer productivity and code maintainability.

In Details

This is a discussion about proposed changes to GCC's internal representation handling, specifically regarding how developers check and cast types within the 'tree' data structure. The proposal, motivated by gradual typing, suggests replacing simple macros like TREE_CODE with C++ dynamic casts (dyn_cast or similar fallible conversions). Reviewers like Jelinek and Botcazou argue this significantly increases verbosity and complexity without clear benefits for the majority of use cases, which involve inspecting diverse tree nodes rather than expecting specific types.

For Context
tree
GCC's internal representation of the Abstract Syntax Tree (AST) and other intermediate forms.
TREE_CODE
A macro used to determine the type or kind of a GCC tree node.
dyn_cast
A C++ RTTI (Run-Time Type Information) mechanism used for safe downcasting, often employed in frameworks like LLVM and proposed here for GCC's tree manipulation.
GIMPLE
GCC's middle-end intermediate representation, a simplified form of the tree AST.
RTL
Register Transfer Language, an intermediate representation used in GCC's backend.
Filed Under: gcccompiler internalsc++type systemergonomics