【发布时间】:2017-11-21 22:20:12
【问题描述】:
我最近玩弄了gcc 中的概念功能,并在类的构造函数或成员函数中使用可变参数概念模板时偶然发现了这个错误:
template<typename From, typename To>
concept bool ConvertibleNoNarrow = requires(From f, To t) {
t = { f };
};
class Foo
{
public:
template<ConvertibleNoNarrow<double>... Args>
Foo(Args&&... args) { /*...*/ }
};
使用Foo时,gcc显示内部错误:
err.cpp: In substitution of ‘template<class ... Args> requires ConvertibleNoNarrow<Args, double>... Foo::Foo(Args&& ...) [with Args = {double}]’: err.cpp:23:11: required from here err.cpp:13:3: internal compiler error: in tsubst_constraint, at cp/constraint.cc:1956 Foo(Args&&... args) { } ^~~
如果在全局函数中使用相同的签名,一切都会按预期工作:
/* works */
template<ConvertibleNoNarrow<double>... Args>
void Test(Args&&... args) { }
任何人都可以重现这种情况或知道为什么会发生这种情况以及如何调用现有的错误报告吗?
编辑:
我的 gcc 版本:
gcc (Gentoo 7.2.0 p1.1) 7.2.0 Copyright (C) 2017 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
【问题讨论】:
-
好像是this bug