[PATCH] D139400: [clang] Show error when a local variables is passed as default template parameter
Tom Honermann via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 13 07:36:32 PST 2022
tahonermann added inline comments.
================
Comment at: clang/test/SemaTemplate/default-template-arguments.cpp:12
+ auto lambda1 = [] <auto y = x_constexpr> {}; // expected-error {{default argument references local variable x_constexpr of enclosing function}}
+ auto lambda2 = [] <auto y = x_static> {}; // expected-error {{default argument references local variable x_static of enclosing function}}
+ auto lambda3 = [] <auto y = x_const> {}; // expected-error {{default argument references local variable x_const of enclosing function}}
----------------
MSVC and Clang currently accept `x_static`. The resolution of [[ https://cplusplus.github.io/CWG/issues/2346.html | CWG 2346 ]] suggests that this case (and maybe `x_constexpr`) should be accepted following the adoption of [[ https://wg21.link/p0588r1 | P0588R1 (Simplifying implicit lambda capture) ]]. However, it isn't obvious to me that P0588R1 actually addresses this. It might be worth following up with CWG to understand what the intent is.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D139400/new/
https://reviews.llvm.org/D139400
More information about the cfe-commits
mailing list