带有虚拟继承的初始化列表中的lambda捕获的gcc bug?

And*_*rew 10 c++ lambda gcc

以下代码在gcc-4.9,5.4和6.3下使用std = c ++ 11进行段错误,但在clang-3.7和VS2015 Update 3下编译并运行正常.

struct A
{
    int Func() { return x++; }
    int x = 5;
};

struct B
{
    B(int) {}
};

struct Derived : public virtual A, public B
{
    Derived()
      : A()
      // , B(this->Func()) // This works!
      , B([this](){ return this->Func(); }()) // But this segfaults.
    {
    }
};

int main()
{
    Derived c;
}
Run Code Online (Sandbox Code Playgroud)

这是gcc中的错误吗?删除虚拟继承可修复segfault.

And*_*rew 2

这已作为 bug 提交给 gcc,并得到确认。

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81051