Requires clauses in pfn conversions for generic lambdas
Project / Subsystem
gcc / gcc
Date
2026-09-12
Proposer
Ivan Sokolov <sugrob9000aero@gmail.com>
Source type
public_inbox
Consensus
Proposed
Sentiment
6/10
Technical tradeoffs
- • Enforcing constraints on lambda-to-function-pointer conversions improves type safety and consistency but might break existing code that relies on GCC's current lenient behavior.
- • Aligning GCC's behavior with Clang's for this feature could improve cross-compiler compatibility.
- • Potential standard defect investigation may lead to further language clarifications or modifications.
All attributes
- project
- gcc
- subsystem
- gcc
- patch_id
- —
- discussion_id
- 20260912030100.325efc83@aabbin
- source_type
- public_inbox
- title
- Requires clauses in pfn conversions for generic lambdas
- headline
- Requires clauses in pfn conversions for generic lambdas
- tldr
- Proposes adding requires clause evaluation to generic lambda conversions to function pointers, matching Clang's behavior.
- proposer
- Ivan Sokolov <sugrob9000aero@gmail.com>
- consensus
- Proposed
- outcome
- proposed
- sentiment_score
- 6
- technical_tradeoffs
-
- • Enforcing constraints on lambda-to-function-pointer conversions improves type safety and consistency but might break existing code that relies on GCC's current lenient behavior.
- • Aligning GCC's behavior with Clang's for this feature could improve cross-compiler compatibility.
- • Potential standard defect investigation may lead to further language clarifications or modifications.
- series_id
- —
- series_role
- standalone
- series_parts
- []
- tags
-
- • c++
- • lambda
- • compiler
- • standard
- • gcc
- bugzilla_url
- —
- date
- 2026-09-12T00:00:00.000Z
Requires clauses in pfn conversions for generic lambdas
This discussion proposes adding support for ‘requires’ clauses in C++ generic lambdas when converting them to function pointers. Currently, GCC does not apply these constraints, leading to ambiguities or internal compiler errors in certain cases, unlike Clang which appears to handle them correctly. The author offers to provide a patch if the change is deemed desirable for GCC and potentially the standard.