static function lookup from a template function issue with xlC

前端 未结 2 923
执念已碎
执念已碎 2021-01-04 23:16

While I was searching for clues about a compilation problem I have had in my source, I have come across this bug report (against Mozilla\'s JavaScript engine source) related

相关标签:
2条回答
  • 2021-01-04 23:56

    Prior to C++11 this was the correct behavior: unqualified name resolution of names used in templates was defined to only find functions with external linkage.

    C++03 section 14.6.4.2 Candidate Functions [temp.dep.candidate] paragraph 1:

    For a function call that depends on a template parameter, if the function name is an unqualified-id but not a template-id, the candidate functions are found using the usual lookup rules (3.4.1, 3.4.2) except that:

    • For the part of the lookup using unqualified name lookup (3.4.1), only function declarations with external linkage from the template definition context are found.

    • For the part of the lookup using associated namespaces (3.4.2), only function declarations with external linkage found in either the template definition context or the template instantiation context are found.

    which changes in C++11 to:

    For a function call that depends on a template parameter, the candidate functions are found using the usual lookup rules (3.4.1, 3.4.2, 3.4.3) except that:

    • For the part of the lookup using unqualified name lookup (3.4.1) or qualified name lookup (3.4.3), only function declarations from the template definition context are found.

    • For the part of the lookup using associated namespaces (3.4.2), only function declarations found in either the template definition context or the template instantiation context are found.

    0 讨论(0)
  • 2021-01-05 00:15

    V12.1 of the compiler has the new behaviour by default.

    If you are using an earlier version of the xlC compiler use option -qdebug=KeepUnqualifiedStaticCandidate

    0 讨论(0)
提交回复
热议问题