public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jakub at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/43912] lambda debug info does not describe captured variables
Date: Tue, 27 Jul 2010 15:14:00 -0000	[thread overview]
Message-ID: <20100727151411.21801.qmail@sourceware.org> (raw)
In-Reply-To: <bug-43912-360@http.gcc.gnu.org/bugzilla/>



------- 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<typename F>
F
foo (int *x, int *y, F f)
{
  for (; x != y; ++x)
    f (*x);
  return f;
}

template<typename T>
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


  reply	other threads:[~2010-07-27 15:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-27 19:57 [Bug c++/43912] New: " tromey at gcc dot gnu dot org
2010-07-27 15:14 ` jakub at gcc dot gnu dot org [this message]
2010-07-28 11:41 ` [Bug c++/43912] " jakub at gcc dot gnu dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100727151411.21801.qmail@sourceware.org \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).