Skip to content

cmake: raise Clang's expression nesting limit - #2185

Merged
jcelerier merged 1 commit into
masterfrom
fix/clang-bracket-depth
Aug 9, 2026
Merged

cmake: raise Clang's expression nesting limit#2185
jcelerier merged 1 commit into
masterfrom
fix/clang-bracket-depth

Conversation

@jcelerier

Copy link
Copy Markdown
Member

Clang caps expression nesting at 256. Avendish assembles the module list with std::tuple_cat, and libstdc++'s tuple constructor folds over every element:

explicit(!(__is_implicitly_default_constructible_v<_Elements> && ...))

giving one term per module. Once the count passes 256 that stops being a diagnostic and becomes a hard error:

/usr/include/c++/14/tuple:965:72: fatal error: instantiating fold expression with 330 arguments exceeded expression nesting limit
  965 |       explicit(!(__is_implicitly_default_constructible_v<_Elements> && ...))
note: in instantiation of template class 'std::tuple<halp::midi_bus<...>, ...>'
note: in instantiation of function template specialization 'std::tuple_cat<...>'
      3rdparty/avendish/include/avnd/concepts/modules.hpp:217

It is at 330 today and only grows as plug-ins are added, so this sets the ceiling well clear rather than just above the current count.

-fbracket-depth is Clang-only and costs nothing when the limit is not reached; GCC has no equivalent cap, so GCC builds are unaffected.

Seen on the clang-20 Ubuntu plucky legs of #2176, #2179, #2181, #2182 and #2183 — 8 failing jobs across those PRs.

Clang caps expression nesting at 256. Avendish assembles the module list with
std::tuple_cat, and libstdc++'s tuple constructor folds over every element:

  explicit(!(__is_implicitly_default_constructible_v<_Elements> && ...))

giving one term per module. Once the count passes 256 that stops being a
diagnostic and becomes a hard error:

  tuple:965: fatal error: instantiating fold expression with 330 arguments
             exceeded expression nesting limit

It is at 330 today and only grows as plug-ins are added, so this raises the
ceiling well clear rather than to the next value above the current count.
Costs nothing when the limit is not reached, and GCC has no equivalent cap.
@jcelerier
jcelerier force-pushed the fix/clang-bracket-depth branch from 04c7f32 to 89a28b5 Compare August 9, 2026 22:59
@jcelerier
jcelerier merged commit c189cd0 into master Aug 9, 2026
33 of 58 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant