Re: Gradual 'tree' typing and C++

Project / Subsystem

gcc / gcc

Date

2026-07-24

Proposer

Joseph Myers <josmyers@redhat.com>

Source type

public_inbox

Consensus

Proposed

Sentiment

/10

Technical tradeoffs

  • Using templates for 'tree' typing increases static analysis benefits and potentially catches errors earlier.
  • Overuse of complex template syntax can decrease readability for developers unfamiliar with advanced C++ features.
  • Explicitly typing 'tree' parameters might reveal poorly designed internal APIs that accept too wide a range of node types.

All attributes

project
gcc
subsystem
gcc
patch_id
discussion_id
96e015e6-d0a2-320f-b4fe-49a0a8812dcd@redhat.com
source_type
public_inbox
title
Re: Gradual 'tree' typing and C++
headline
Gradual 'tree' typing and C++
tldr
Discussion on C++ template syntax for GCC's internal 'tree' types and its impact on code readability.
proposer
Joseph Myers <josmyers@redhat.com>
consensus
Proposed
outcome
proposed
sentiment_score
technical_tradeoffs
  • Using templates for 'tree' typing increases static analysis benefits and potentially catches errors earlier.
  • Overuse of complex template syntax can decrease readability for developers unfamiliar with advanced C++ features.
  • Explicitly typing 'tree' parameters might reveal poorly designed internal APIs that accept too wide a range of node types.
series_id
series_role
standalone
series_parts
[]
tags
  • compiler
  • gcc
  • C++
  • templates
  • internal representation
bugzilla_url
date
2026-07-24T00:00:00.000Z

Re: Gradual 'tree' typing and C++

This discussion debates the merits of using C++ templates for GCC’s internal ‘tree’ type, specifically proposing syntax like foo(tree<one_of<FUNCTION_DECL, PLUS_EXPR>> x). While proponents see it as an improvement over assertions in function bodies, others argue it makes functions appear ‘weird’ and can lead to writing bad code. The core disagreement lies in whether explicit static typing of internal compiler data structures enhances or detracts from code clarity and design.