【发布时间】:2013-07-15 18:31:16
【问题描述】:
当我在寻找有关我在源代码中遇到的编译问题的线索时,我遇到了这个与函数查找相关的bug report (against Mozilla's JavaScript engine source)。引用错误报告:
TypedArrayTemplate (显然)是一个模板,它引用 INT_TO_JSVAL,一个静态内联函数,而不用前缀“::”。这会破坏 xlC,因为它无法解析 INT_TO_JSVAL。如果在模板参数的上下文中找不到非限定名称,则该标准不要求考虑静态。 g++ 做这个后备,xlC 没有。
来自编译器的信息性消息:
(I) Static declarations are not considered for a function call if the function is not qualified.
在我的例子中,失败的代码类似于:
namespace N
{
static bool foo (std::string const &);
template <typename T>
void bar (T const &, std::string const & s)
{
// expected unqualified call to N::foo()
foo (s);
}
void baz (std::string const & s)
{
bar (s);
}
} // namespace N
xlC 实现的行为真的正确吗? 2003 年或 2011 年的标准在哪里谈到了这一点?
【问题讨论】:
标签: c++ templates name-lookup xlc