Uploaded image for project: 'ROOT'
  1. ROOT
  2. ROOT-8826

Cannot use lambda captures from root prompt

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Critical
    • Resolution: Fixed
    • None
    • 6.12/00
    • Cling
    • None
    • all?

    Description

      Given

      root [0] int a;

      the following statements fail to be interpreted correctly:

      root [1] auto l1 = [a] {};
      root [2] auto l2 = [&a] {};

      The error reported at prompt is the following:

      ROOT_prompt_1:1:11: error: 'a' cannot be captured because it does not have automatic storage duration

      The following also does not behave as intended:

      root [0] int a = 42;
      root [1] auto l = [=] { return a; }
      root [2] ++a;
      root [3] l(); // prints 43 instead of 42. copy was not by value

      Additionally, defining a lambda without assigning it to a variable is not supported:

      root [0] [] {}
      input_line_9:1:58: error: use of undeclared identifier 'lambda'
      extern "C" void __cling_Destruct_0x13a30f0(void* obj){(((lambda)*)obj)->~();}
                                                               ^
      input_line_9:1:66: error: expected expression
      extern "C" void __cling_Destruct_0x13a30f0(void* obj){(((lambda)*)obj)->~();}
                                                                       ^
      input_line_9:1:74: error: expected a class name after '~' to name a destructor
      extern "C" void __cling_Destruct_0x13a30f0(void* obj){(((lambda)*)obj)->~();}
                                                                               ^
      () @0x11ef910

      Attachments

        Activity

          People

            axel Axel Naumann
            eguiraud Enrico Guiraud
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: