IBM Support

LI77602: MISSING DEFAULT ARGUMENT ON MEMBER FUNCTION

Subscribe

You can track all active APARs for this component.

APAR status

  • Closed as program error.

Error description

  • When compiling the following testcase, the compiler issues an
    error related to the number of arguments for a specific
    function when it should not.
    
    ===== COMPILE COMMAND:
    xlC -c b.cpp
    
    ===== TESTCASE:
    $ cat b.cpp
    typedef unsigned long size_t;
    
    typedef unsigned long _Bit_type;
    enum { _S_word_bit = int(8 * sizeof(_Bit_type)) };
    
     struct _Bit_iterator_base
      {};
    
    
    struct _Bit_iterator : public _Bit_iterator_base
      {
      };
    
    template<class _Alloc> struct _Bvector_base
    {
         typedef typename _Alloc::template rebind<_Bit_type>::other
    _Bit_alloc_type;
    
         struct _Bvector_impl : public _Bit_alloc_type
         {
         _Bit_iterator  _M_start;
         _Bit_iterator  _M_finish;
         _Bit_type*  _M_end_of_storage;
         _Bvector_impl(const _Bit_alloc_type& __a) ;
         };
    
          typedef _Alloc allocator_type;
    
          _Bvector_base(const allocator_type& __a) ;
    
    
      _Bvector_impl _M_impl;
    
         _Bit_type*  _M_allocate(size_t __n)
         { return _M_impl.allocate((__n + int(_S_word_bit) - 1) /
    int(_S_word_bit)); }
    
    };
    
    
    template <typename T>
    struct Allocator
    {
       typedef size_t    size_type;
       typedef T *       pointer;
    
       Allocator();
    
       template <typename U>
       struct rebind
       {
          typedef Allocator<U> other;
       };
    
       pointer allocate( size_type n, const void* hint = 0);
    
    };
    
    void tester(size_t a)
    {
       Allocator<bool> alloc;
       _Bvector_base<Allocator<bool> > x(alloc);
       x._M_allocate(a);
    }
    $
    
    
    
    ===== ACTUAL OUTPUT:
    $ xlC b.cpp -c
    "b.cpp", line 43.31: 1540-0215 (S) The wrong number of
    arguments has been specified for "Allocator<unsigned
    long>::allocate(size_type, const void *)".
    "b.cpp", line 41.18: 1540-0700 (I) The previous message was
    produced while processing "_Bvector_base<Allocator<bool>
    >::_M_allocate(size_t)".
    "b.cpp", line 73.5: 1540-0700 (I) The previous message was
    produced while processing "tester(size_t)".
    $
    
    
    ===== EXPECTED OUTPUT:
    Clean compile
    

Local fix

  • Workaround by specifying the default argument in the call
    
    <      { return _M_impl.allocate((__n + int(_S_word_bit) - 1) /
    int(_S_word_bit)); }
    ---
    >      { return _M_impl.allocate((__n + int(_S_word_bit) - 1) /
    int(_S_word_bit),0); }
    

Problem summary

  • USERS AFFECTED:
    The problem may be seen when using a default argument from an
    inline member function of a template class.
    If there is a call to a function with a default, that call uses
    the default and the function with the default is after the
    call.
    The compile may not pick up the default argument in specific
    cases.
    
    PROBLEM DESCRIPTION:
    The compiler missed picking up a default argument.
    

Problem conclusion

  • The compiler has been fixed to pick up the default argument.
    

Temporary fix

Comments

APAR Information

  • APAR number

    LI77602

  • Reported component name

    XL C/C++ FOR LI

  • Reported component ID

    5725C7300

  • Reported release

    C10

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt

  • Submitted date

    2013-10-25

  • Closed date

    2013-10-28

  • Last modified date

    2013-10-28

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

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

    LI77873 IV56821

Fix information

  • Fixed component name

    XL C/C++ FOR LI

  • Fixed component ID

    5725C7300

Applicable component levels

  • RC10 PSY

       UP



Document information

More support for: XL C/C++ for Linux
Compiler

Software version: 12.1

Reference #: LI77602

Modified date: 28 October 2013