Bug 102610 - [C++23] P2036R3 - Change scope of lambda trailing-return-type
Summary: [C++23] P2036R3 - Change scope of lambda trailing-return-type
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 12.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
Depends on:
Blocks: c++23-core
  Show dependency treegraph
Reported: 2021-10-05 16:13 UTC by Marek Polacek
Modified: 2023-08-31 11:38 UTC (History)
2 users (show)

See Also:
Known to work:
Known to fail:
Last reconfirmed: 2022-08-16 00:00:00


Note You need to log in before you can comment on or make changes to this bug.
Description Marek Polacek 2021-10-05 16:13:54 UTC
See https://wg21.link/p2036r3
Comment 1 Marek Polacek 2022-08-16 16:16:52 UTC
https://wg21.link/p2579r0, Mitigation strategies for P2036 ”Changing scope for lambda trailing-return-type”, was also approved.
Comment 2 Jakub Jelinek 2023-08-31 11:38:44 UTC
Related question for the last paper: https://github.com/cplusplus/draft/issues/6536
Other than that, I guess opening a new sk_lambda scope in cp_parser_lambda_declarator_opt at the start and leaving it at the end should be easy,
but we only build_capture_proxy later on.  Shall we pushdecl into the sk_lambda scope
instead the LAMBDA_CAPTURE_EXPLICIT_P && !DECL_NORMAL_CAPTURE_P captures and somehow special-case them in name lookup or just finish_decltype_type where we currently handle
      if (outer_automatic_var_p (expr)
          && current_function_decl
          && LAMBDA_FUNCTION_P (current_function_decl))
        type = capture_decltype (expr);
case?  Though, in the lambda declarator, current_function_decl is still the containing function and outer_automatic_var_p also will not work.  I guess we need some way to know whether we are in the lambda declarator (and also whether it is before the end of
parameter declarations or after and whether in the latter case the lambda is mutable or not) and special case in that case both the init-captures and automatic? vars from the current function (which will be outer vars in lambda body).