TBB 编译器错误 - 'my_task':必须初始化引用

TBB compiler error - 'my_task': references must be initialized

我在项目的多个地方使用了 TBB。但似乎自从我将 Visual Studio 从 15.6.X (X beeing 最新版本)更新到 15.7.1 后,我在几个地方遇到了编译器错误,告诉我

[...]tbb\task_group.h(94): error C2530: 'my_task': references must be initialized

查看参考代码(tbb/task_group.h):

//! Base class for types that should not be assigned.
class no_assign {
    // Deny assignment
    void operator=( const no_assign& );
public:

#if __GNUC__
    //! Explicitly define default construction, because otherwise gcc issues gratuitous warning.
    no_assign() {}
#endif /* __GNUC__ */
};

//! Base class for types that should not be copied or assigned.
class no_copy: no_assign {
    //! Deny copy construction
    no_copy( const no_copy& );
public:
    //! Allow default construction
    no_copy() {}
};

// ...

class ref_count_guard : internal::no_copy {
    task& my_task;  // compiler error occurs here
public:
    ref_count_guard( task& t ) : my_task(t) {
        my_task.increment_ref_count();
    }
    ~ref_count_guard() {
        my_task.decrement_ref_count();
    }
};

我不明白为什么编译器会在那里抱怨,因为引用是由构造函数初始化的。在我的代码中找到问题也不是那么容易,因为编译器错误发生在每个使用 TBB 的源文件中,而且我认为自上次成功编译以来我没有做任何更改(除了更新 VS)。

我想到的一种可能性与 this question. If msvc somehow inherits the base class constructors by default, a default constructor would be inherited explaining the error. But testing 这种情况似乎反驳了它(在代码编译时)。

为什么 msvc 在这里抱怨?

更新

这个最小的例子在我的系统上重现了错误:

#include <vector>
#include <tbb/tbb.h>
#include <tbb/flow_graph.h>       

void main()
{
    std::vector<int> src{1, 2, 3, 4, 5};
    tbb::parallel_for_each(src.begin(), src.end(), [](int) { });
}

更新 2

似乎只包含 tbb/tbb.h 就会导致错误发生。我什至不需要打电话给任何人。使用新的编译器版本重建 tbb 也没有帮助。

编辑

交叉问题 github

只需删除 /permissive-(例如,在 C/C++ 选项中将一致性模式设置为否)即可解决此问题。我想英特尔很快就会解决这个问题。

这是使用 /permissive- 选项时的编译器错误。可以使用以下代码重现:

struct U {
    template<typename T>
    void foo() {
        class A {
            int& iref;
        public:
            A(int& ir) : iref(ir) { }
        };
        int the_answer = 42;
        A a(the_answer);
    }
};

int main() {
    U u;
    u.foo<int>();
    return 0;
}

代码完全有效,兼容 C++。如您所见,引用在构造函数的成员初始化列表中被显式初始化。此外,这似乎是 VS 中的回归,因为至少 VS 2017 的初始版本(15.0.something)使用 /permissive-.

编译此代码