Opened 11 years ago

Closed 11 years ago

#5913 closed Bugs (invalid)

Boost.Asio interferes with C++0x-Lambdas having [this]-Capture on MSVC2010

Reported by: boost@… Owned by:
Milestone: To Be Determined Component: None
Version: Boost 1.46.1 Severity: Not Applicable
Keywords: Cc:

Description

Short Code to reproduce the Problem:

#include <boost/asio/io_service.hpp>

struct Data {
  int i;
};

struct Foo {
  Data* data;

  void bar() {
    auto callback = [this]() { 
      data->i = 5;
    };
  }
};

Gives an error on line 10: error C2326: 'void `anonymous-namespace'::<lambda0>::operator ()(void) const': function can not access 'Foo::data'

removing the #include fixes the error as well as specifying the access by this->data->i = 5;

Setup used: MSVC2010 Ultimate with Boost 1.46.1

Change History (1)

comment:1 by boost@…, 11 years ago

Resolution: invalid
Severity: ProblemNot Applicable
Status: newclosed

Ok, I reduced the Problem to the following Code, so it's a MSVC bug:

namespace n1 {
  class far_away {
    struct data {};
  };
} //ns n1

namespace n2 {
  struct Data {
    int i;
  };

  struct Foo {
    Data* data;

    void bar() {
      auto callback = [this]() { 
        data->i = 5;
      };
    }
  };
} //ns n2
Note: See TracTickets for help on using tickets.