IBM Support

LI71532: TEMPLATE CLASS WITH SINGLE OPERATOR= GIVES NO BEST MATCH ERROR

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as program error.

Error description

  • Compiler claims 'The call to "operator=" has no best match.'
    when in fact there is only one operator= that matches the call.
    This happens in a simple case of a template class with a single
    operator= function.  The compiler seems to find a conflict
    between the operator= and itself.
    
    TESTCASE:
    ---------
    template <class _T>
    class C
    {
    public:
            C<_T>& operator= (_T* pt)
            {
                    return *this;
            }
            void fn() {
                    operator= (0);
            }
    };
    
    extern void f ()
    {
            C<int> c;
            c.fn();
    }
    
    Actual Output:
    --------------
    xlC t.C
    "t.C", line 10.17: 1540-0219 (S) The call to "operator=" has no
    best match.
    "t.C", line 10.17: 1540-1230 (I) Argument number 1 is the
    implicit "this" argument.
    "t.C", line 10.28: 1540-1229 (I) Argument number 2 is an rvalue
    of type "int".
    "t.C", line 5.16: 1540-1202 (I) No candidate is better than
    "C<int>::operator=(int *)".
    "t.C", line 10.17: 1540-1231 (I) The conversion from argument
    number 1 to "C<int> &" uses "the identity conversion".
    "t.C", line 10.28: 1540-1231 (I) The conversion from argument
    number 2 to "int *" uses "a pointer conversion".
    "t.C", line 5.16: 1540-1202 (I) No candidate is better than
    "C<int>::operator=(int *)".
    "t.C", line 10.17: 1540-1231 (I) The conversion from argument
    number 1 to "C<int> &" uses "the identity conversion".
    "t.C", line 10.28: 1540-1231 (I) The conversion from argument
    number 2 to "int *" uses "a pointer conversion".
    "t.C", line 9.14: 1540-0700 (I) The previous message was
    produced while processing "C<int>::fn()".
    "t.C", line 17.10: 1540-0700 (I) The previous message was
    produced while processing "f()".
    

Local fix

  • use -qlanglvl=noDependentBaseLookup
    

Problem summary

  • The presense of operator= in a template class sometimes led to
    a duplicate declaration in the list of overload candidates.
    The duplicate will cause overload resolution to fail
    complaining about 2 candidates that are actually the same
    

Problem conclusion

  • The error has been fixed so that no duplicates appear in the
    list of candidates in this case. Please apply the PTF.
    

Temporary fix

Comments

APAR Information

  • APAR number

    LI71532

  • Reported component name

    XLC/C++ RHEL4

  • Reported component ID

    5724M1610

  • Reported release

    800

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt

  • Submitted date

    2006-09-14

  • Closed date

    2006-09-14

  • Last modified date

    2006-09-14

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

    IY85336

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

Fix information

  • Fixed component name

    XLC/C++ RHEL4

  • Fixed component ID

    5724M1610

Applicable component levels

  • R800 PSN

       UP

[{"Business Unit":{"code":"BU054","label":"Systems w\/TPS"},"Product":{"code":"SSJT9L","label":"XL C\/C++"},"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"8.0","Line of Business":{"code":"LOB08","label":"Cognitive Systems"}}]

Document Information

Modified date:
15 October 2021