Landing: c8498d405a5a

Project / Subsystem

gcc / c++/reflection

Date

2026-05-06

Author

Patrick Palka

Commit

c8498d405a5abb276caa06f6a8952aa26637f1db

Source

github

Perf win

Yes

Breaking

No

All attributes

project
gcc
subsystem
c++/reflection
patch_id
commit_hash
c8498d405a5abb276caa06f6a8952aa26637f1db
source_type
github
headline
Rewrite and memoize consteval_only_p for C++ reflection.
tldr
Speeds up compile times with C++ reflection by rewriting and memoizing the consteval_only_p predicate.
author
Patrick Palka
outcome
committed
performance_win
true
breaking_change
false
series_id
series_parts
[]
tags
  • c++
  • reflection
  • optimization
  • compile time
discussion_id_link
bugzilla_pr
date
2026-05-06T00:00:00.000Z

Speeds up compile times when using C++ reflection. The consteval_only_p predicate, which checks if a type can only be evaluated at compile time, was found to be slow due to its recursive nature. This commit rewrites the predicate for clarity and efficiency, introduces a tri-state to handle incomplete class types, and caches results to avoid redundant calculations. Compile time for a test case is reduced from 40x to 1.1x compared to builds without reflection.