IBM Support

IV11365: TEMPLATE INSTANTIATION PROBLEM

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as program error.

Error description

  • Consider the following test.cpp:
    
    ///////////// test.cpp //////////////////////
    struct A {
      int bar() { return 0; }
      int bar() const { return 1; }
    };
    template<typename T> void foo(T A::*) { }            // (1)
    template<typename T> void foo(T (A::*)() const) { }  // (2)
    int main() { foo(&A::bar); }                         // should
    expand via (2) above
    // XL C/C++ compiler cannot decide between (1) & (2)
    //////////////end of test.cpp ///////////////
    
    $xlC test.cpp
    "test.cpp", line 7.14: 1540-0219 (S) The call to "foo" has no
    best match.
    "test.cpp", line 7.18: 1540-1229 (I) Argument number 1 is an
    rvalue of type "overloaded function: A::bar".
    "test.cpp", line 6.27: 1540-1202 (I) No candidate is better
    than "foo<int>(int (A::*)() const)".
    "test.cpp", line 7.18: 1540-1231 (I) The conversion from
    argument number 1 to "int (A::*)() const" uses the resolved
    overloaded function "int A::bar() const".
    "test.cpp", line 5.27: 1540-1202 (I) No candidate is better
    than "foo<int ()>(int (A::*)())".
    "test.cpp", line 7.18: 1540-1231 (I) The conversion from
    argument number 1 to "int (A::*)()" uses the resolved overloaded
    function "int A::bar()".
    

Local fix

  • N/A
    

Problem summary

  • When applying template argument deduction with a type A that is
    a pointer to non-static member function type, the corresponding
    type P must match the cv-qualifier-seq of the type A exactly
    when using XL C/C++ for deduction to succeed. This may cause
    deduction to succeed where it would otherwise fail when the
    type of A is the address of a member function overloaded on the
    cv-qualifier-seq.
    

Problem conclusion

  • Fix is enabled with -qxflag=FunctionCVTmplArgDeduction2011
    which also sets macro __IBMCPP_FUNC_CV_TMPL_ARG_DEDUCTION to 1.
    The new behaviour may become the default in a future release.
    Handling of cv-qualifier-seq in function types and
    cv-qualification is modified in template argument deduction.
    

Temporary fix

Comments

APAR Information

  • APAR number

    IV11365

  • Reported component name

    XL C/C++ AIX

  • Reported component ID

    5724X1300

  • Reported release

    B10

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt

  • Submitted date

    2011-11-29

  • Closed date

    2012-01-09

  • Last modified date

    2012-01-09

  • APAR is sysrouted FROM one or more of the following:

  • APAR is sysrouted TO one or more of the following:

    LI76650

Fix information

  • Fixed component name

    XL C/C++ AIX

  • Fixed component ID

    5724X1300

Applicable component levels

  • RB10 PSY U849548

       UP C

[{"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SSGH3R","label":"XL C\/C++ for AIX"},"Component":"","ARM Category":[],"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"11.1","Edition":"","Line of Business":{"code":"LOB57","label":"Power"}}]

Document Information

Modified date:
09 January 2012