http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49554

           Summary: [4.7 Regression] [C++0x] lambda capture causes "cannot
                    call member function ... without object"
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Keywords: rejects-valid
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: r...@gcc.gnu.org
                CC: ja...@gcc.gnu.org


template<typename T>
  struct base
  {
    struct iterator { };

    iterator begin();
  };

template<typename T>
class flist : public base<T>
{
  typedef base<T> Base;

  typedef typename Base::iterator Base_iterator;
public:

  void
  resize()
  {
    Base_iterator b = Base::begin();

    [b](int i) { return i; };
  }
};

void test01()
{
  flist<int> fl;
  fl.resize();
}


objexpr.ii: In lambda function:
objexpr.ii:22:6:   required from ‘struct flist<T>::resize() [with T =
int]::<lambda(int)>’
objexpr.ii:22:5:   required from ‘void flist<T>::resize() [with T = int]’
objexpr.ii:29:13:   required from here
objexpr.ii:20:19: error: cannot call member function ‘base<T>::iterator
base<T>::begin() [with T = int]’ without object

If 'b' is not captured there's no error

This breaks <debug/forward_list> in libstdc++

Reply via email to