From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21914 invoked by alias); 27 Jul 2010 15:14:30 -0000 Received: (qmail 21802 invoked by uid 48); 27 Jul 2010 15:14:11 -0000 Date: Tue, 27 Jul 2010 15:14:00 -0000 Message-ID: <20100727151411.21801.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug c++/43912] lambda debug info does not describe captured variables In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "jakub at gcc dot gnu dot org" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2010-07/txt/msg02980.txt.bz2 ------- Comment #1 from jakub at gcc dot gnu dot org 2010-07-27 15:14 ------- I've briefly looked at this. For !processing_template_decl, it shouldn't be hard to walk LAMBDA_EXPR_CAPTURE_LIST e.g. in cp_parser_lambda_expression and add copy_decl of the vars from the capture list with DECL_VALUE_EXPR pointing to this->__fieldname or *this->__fieldname. Templates slightly complicate that though, as if this was to be done say in build_lambda_object guarded with !processing_template_decl, lambda_function probably doesn't have body instantiated yet. And if cp_parser_lambda_expression does this unconditionally, we'd need to handle tsubsting DECL_VALUE_EXPRs. Or we could add them during genericization of the lambda function, but we'd then need to be able to find the corresponding LAMBDA_EXPR from the FUNCTION_DECL. Another thing is whether it is right to call the __lambda* argument this. Even when it is artificial, it is still visible to the user in the debugger. Shouldn't it be made DECL_NAMELESS once the vars with DECL_VALUE_EXPR are added? Jason, what do you prefer here? Testcase I was playing with: extern "C" void abort (); template F foo (int *x, int *y, F f) { for (; x != y; ++x) f (*x); return f; } template void bar (T *w) { T s = 0, t = 0, u = 0, v = 10; foo (&w[0], &w[10], [&s, &t, u, v] (T &a) -> void { s += a; t += s + 10 - v; }); if (s != 45 || t != 165) abort (); } int main () { int s = 0, t = 0, u = 10, v = 10; int w[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; foo (&w[0], &w[10], [&s, &t, u, v] (int &a) -> void { s += a; t += s + 10 - v; }); if (s != 45 || t != 165) abort (); bar (w); return 0; } -- jakub at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jason at gcc dot gnu dot org Status|UNCONFIRMED |NEW Ever Confirmed|0 |1 Last reconfirmed|0000-00-00 00:00:00 |2010-07-27 15:14:11 date| | http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43912