【发布时间】:2021-02-17 21:49:45
【问题描述】:
在 Linux/x86-64 的 RefPerSys GPLv3+ 项目(在 Debian/Sid 系统上),git commit 37172c9af257865d,使用 GCC 10 编译,调用为 g++ -std=gnu++17 -Og -g3 -Wall -Wextra 等。 . 我收到以下错误消息:
refpersys.hh: In instantiation of ‘PaylClass* Rps_ObjectZone::put_new_arg3_payload(Arg1Class, Arg2Class, Arg3Class) [with PaylClass = Rps_PayloadWebex; Arg1Class = long unsigned int; Arg2Class = Onion::Request*; Arg3Class = Onion::Response*]’:
httpweb_rps.cc:314:71: required from here
refpersys.hh:2162:76: error: no matching function for call to ‘Rps_ObjectZone::rps_allocate4<Rps_PayloadWebex, long unsigned int, Onion::Request*, Onion::Response*>(Rps_ObjectZone*, long unsigned int&, Onion::Request*&, Onion::Response*&)’
2162 | Zone::rps_allocate4<PaylClass,Arg1Class,Arg2Class,Arg3Class>(this,arg1,arg2,arg3);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
In file included from headweb_rps.hh:37,
from httpweb_rps.cc:34:
refpersys.hh:1701:3: note: candidate: ‘template<class ZoneClass, class Arg1Class, class Arg2Class, class Arg3Class, class Arg4Class> static ZoneClass* Rps_QuasiZone::rps_allocate4(Arg1Class, Arg2Class, Arg3Class, Arg4Class)’
1701 | rps_allocate4(Arg1Class arg1, Arg2Class arg2, Arg3Class arg3, Arg4Class arg4)
| ^~~~~~~~~~~~~
refpersys.hh:1701:3: note: template argument deduction/substitution failed:
In file included from headweb_rps.hh:37,
from httpweb_rps.cc:34:
refpersys.hh:2162:76: note: cannot convert ‘(Rps_ObjectZone*)this’ (type ‘Rps_ObjectZone*’) to type ‘long unsigned int’
2162 | Zone::rps_allocate4<PaylClass,Arg1Class,Arg2Class,Arg3Class>(this,arg1,arg2,arg3);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
我不能轻易举一个小例子,但我能够给出以下解释。它是关于使用多线程实现(和 Web 界面,使用我们的精确跟踪垃圾收集器)实现一些动态类型语言(如规则的专家系统,在语义上受 Common Lisp 启发)。
主头文件是refpersys.hh,到处都是#included。伴随头文件是headweb_rps.hh,仅与使用libonion 的Web 相关代码相关,这是一些HTTP 服务器库(具有命名空间Onion::),它是#includeing refpersys.hh 标头。
没有使用 C++ 意义上的多重继承。
我们有一个枚举 Rps_Type(在文件 refpersys.hh 第 903 行中)定义了一些 tagged union 类型的标签。标记的联合类型是顶级类 Rps_TypedZone(在文件 refpersys.hh 第 1630 行中),在 refpersys.hh 第 1637 行中定义了一个明显的构造函数 Rps_TypedZone::Rps_TypedZone(const Rps_Type ty)。
我们有一个Rps_TypedZone 的class Rps_QuasiZone 子类(在文件refpersys.hh 第1646 行)。
我们有Rps_QuasiZone 的class Rps_ZoneValue(在refpersys.hh:1755)子类。
class Rps_ObjectZone(在refpersys.hh:1964 中)是Rps_ZoneValue 的子类。让我们调用 RefPerSys 对象 Rps_ObjectZone 的子类的任何 C++ 实例。
class Rps_ObjectRef(在 refpersys.hh:694 中)是我们经过 GC 处理的指向 Rps_ObjectZone 的智能指针。
class Rps_Value(在 refpersys.hh:967 中)是一个单字智能指针(有点像 Common Lisp 中的 SBCL-value 一样)。
class Rps_Payload(在refpersys.hh:2264 中)在Rps_ObjectZone 中携带一些可选的额外数据。每个这样的有效负载都属于单个 RefPerSys 对象(一些 Rps_ObjectZone),称为其所有者。
Rps_ObjectZone 的put_new_arg3_payload 模板成员函数很简单(在refpersys.hh:2157 和以下行中),ob_payload 是Rps_ObjectZone 的成员字段,在refpersys.hh:1981 行中声明为std::atomic<Rps_Payload*> ob_payload;:
PaylClass* put_new_arg3_payload(Arg1Class arg1, Arg2Class arg2, Arg3Class arg3)
{
std::lock_guard<std::recursive_mutex> gu(ob_mtx);
PaylClass*newpayl =
Rps_QuasiZone::rps_allocate4<PaylClass,Arg1Class,Arg2Class,Arg3Class>(this,arg1,arg2,arg3);
Rps_Payload*oldpayl = ob_payload.exchange(newpayl);
if (oldpayl)
delete oldpayl;
return newpayl;
}; // end put_new_arg3_payload
许多 Web 交互(即 HTTP 请求,在 C++ 中为 Onion::Request,以及相应的 HTTP 回复,在 C++ 中为 Onion::Reply,其本身是 C++ std::ostream 的子类)被具体化为 @987654373 的 C++ 实例@ 在文件 headweb_rps.hh 第 65 行声明,是 Rps_Payload 的子类。
模板成员函数Rps_QuasiZone::rps_allocate4(在refpersys.hh:1699行)定义为:
template <typename ZoneClass, typename Arg1Class, typename Arg2Class, typename Arg3Class, typename Arg4Class>
static ZoneClass*
rps_allocate4(Arg1Class arg1, Arg2Class arg2, Arg3Class arg3, Arg4Class arg4)
{
return new(nullptr) ZoneClass(arg1, arg2, arg3, arg4);
};
我们的“解释器”的调用框架被具体化为class Rps_ProtoCallFrame;,我们有(在refpersys.hh 第691 行)typedef Rps_ProtoCallFrame Rps_CallFrame;
class Rps_ProtoCallFrame 是在refpersys.hh:2823 中定义的Rps_TypedZone 的子类。
故障线httpweb_rps.cc:314在里面:
Rps_ObjectRef
Rps_PayloadWebex::make_obwebex(Rps_CallFrame*callerframe, Onion::Request*req, Onion::Response*resp,
uint64_t reqnum)
{
RPS_ASSERT(callerframe != nullptr && callerframe->is_good_call_frame());
RPS_ASSERT(req != nullptr);
RPS_ASSERT(resp != nullptr);
auto web_exchange_ob = RPS_ROOT_OB(_8zNtuRpzXUP013WG9S);
RPS_DEBUG_LOG(WEB, "Rps_PayloadWebex::make_obwebex start reqnum#" << reqnum
);
RPS_LOCALFRAME(/*descr:*/ web_exchange_ob,
/*prev:*/callerframe,
/*locals:*/
Rps_ObjectRef obwebex);
_f.obwebex = Rps_ObjectRef::make_object(&_, web_exchange_ob);
auto paylwebex = ////////////////////////////////////// FAULTY LINE BELOW
_f.obwebex->put_new_arg3_payload<Rps_PayloadWebex>(reqnum,req,resp);
RPS_DEBUG_LOG(WEB, "Rps_PayloadWebex::make_obwebex end reqnum#" << reqnum
<< " obwebex=" << _f.obwebex << " startim:" << paylwebex->webex_startim);
RPS_ASSERT(paylwebex != nullptr);
return _f.obwebex;
} // end PayloadWebex::make_obwebex
在上面的代码中,RPS_ASSERT、RPS_ROOT_OB、RPS_LOCALFRAME、RPS_DEBUG_LOG 是 C++ 宏。上述代码的宏展开为:
Rps_ObjectRef
Rps_PayloadWebex::make_obwebex(Rps_CallFrame*callerframe, Onion::Request*req, Onion::Response*resp,
uint64_t reqnum)
{
do { if (__builtin_expect(!!(!((callerframe != nullptr
&& callerframe->is_good_call_frame()))),0))
{ fprintf(
//# 302 "httpweb_rps.cc" 3
stderr
//# 302 "httpweb_rps.cc"
, "\n\n" "%s*** RefPerSys ASSERT failed: %s%s\n" "%s:%d: {%s}\n\n", (rps_stderr_istty?(rps_without_terminal_escape?"":"\033[1m"):""),
"(callerframe != nullptr && callerframe->is_good_call_frame())",
(rps_stderr_istty?(rps_without_terminal_escape?"":"\033[0m"):""),
"httpweb_rps.cc",302,__PRETTY_FUNCTION__);
rps_fatal_stop_at("httpweb_rps.cc",302); }}
while(0);
do
{ if (__builtin_expect(!!(!((req != nullptr))),0)) {
fprintf(
//# 303 "httpweb_rps.cc" 3
stderr
//# 303 "httpweb_rps.cc"
, "\n\n" "%s*** RefPerSys ASSERT failed: %s%s\n" "%s:%d: {%s}\n\n",
(rps_stderr_istty?(rps_without_terminal_escape?"":"\033[1m"):""), "(req != nullptr)",
(rps_stderr_istty?(rps_without_terminal_escape?"":"\033[0m"):""), "httpweb_rps.cc",303,__PRETTY_FUNCTION__);
rps_fatal_stop_at("httpweb_rps.cc",303); }} while(0);
do { if (__builtin_expect(!!(!((resp != nullptr))),0)) {
fprintf(
//# 304 "httpweb_rps.cc" 3
stderr
//# 304 "httpweb_rps.cc"
, "\n\n" "%s*** RefPerSys ASSERT failed: %s%s\n" "%s:%d: {%s}\n\n",
(rps_stderr_istty?(rps_without_terminal_escape?"":"\033[1m"):""), "(resp != nullptr)",
(rps_stderr_istty?(rps_without_terminal_escape?"":"\033[0m"):""), "httpweb_rps.cc",304,__PRETTY_FUNCTION__);
rps_fatal_stop_at("httpweb_rps.cc",304); }} while(0);
auto web_exchange_ob = rps_rootob_8zNtuRpzXUP013WG9S;
do { if ((rps_debug_flags & (1 << RPS_DEBUG_WEB)))
{ std::ostringstream _logstream_306;
_logstream_306 << "Rps_PayloadWebex::make_obwebex start reqnum#" << reqnum << std::flush;
rps_debug_printf_at("httpweb_rps.cc", 306, RPS_DEBUG_WEB,
"%s", _logstream_306.str().c_str()); } } while (0)
;
struct RpsFrameData308 {/*locals:*/ Rps_ObjectRef obwebex; };
typedef Rps_FieldedCallFrame<RpsFrameData308> Rps_FldCallFrame308;
class Rps_FrameAt308 : public Rps_FldCallFrame308
{ public:
Rps_FrameAt308(Rps_ObjectRef obd308, Rps_CallFrame* prev308) :
Rps_FldCallFrame308(obd308, prev308) { }; };
Rps_FrameAt308 _((/*descr:*/ web_exchange_ob),(/*prev:*/callerframe));
auto& _f = *_.fieldsptr();
;
_f.obwebex = Rps_ObjectRef::make_object(&_, web_exchange_ob);
auto paylwebex =
_f.obwebex->put_new_arg3_payload<Rps_PayloadWebex>(reqnum,req,resp);
do { if ((rps_debug_flags & (1 << RPS_DEBUG_WEB)))
{ std::ostringstream _logstream_315;
_logstream_315 << "Rps_PayloadWebex::make_obwebex end reqnum#"
<< reqnum << " obwebex=" << _f.obwebex << " startim:"
<< paylwebex->webex_startim << std::flush; rps_debug_printf_at("httpweb_rps.cc",
315, RPS_DEBUG_WEB, "%s",
_logstream_315.str().c_str()); } } while (0)
;
do { if (__builtin_expect(!!(!((paylwebex != nullptr))),0)) {
fprintf(
//# 317 "httpweb_rps.cc" 3
stderr
//# 317 "httpweb_rps.cc"
, "\n\n" "%s*** RefPerSys ASSERT failed: %s%s\n" "%s:%d: {%s}\n\n",
(rps_stderr_istty?(rps_without_terminal_escape?"":"\033[1m"):""), "(paylwebex != nullptr)",
(rps_stderr_istty?(rps_without_terminal_escape?"":"\033[0m"):""), "httpweb_rps.cc",317,__PRETTY_FUNCTION__);
rps_fatal_stop_at("httpweb_rps.cc",317); }} while(0);
return _f.obwebex;
} // end PayloadWebex::make_obwebex
我做错了什么?
【问题讨论】:
-
为什么是近距离投票? 我努力提供最少但需要的信息!如果我能够简化这个问题,我可能会自己解决它。
标签: c++ linux inheritance gcc c++17