AIX

AIX

Connect with fellow AIX users and experts to gain knowledge, share insights, and solve problems.


#Power
 View Only
Expand all | Collapse all

compilation error: AIX 5.3 and XL C/C++ Enterprise Edition V8.0

  • 1.  compilation error: AIX 5.3 and XL C/C++ Enterprise Edition V8.0

    Posted Wed August 29, 2007 12:11 PM

    Originally posted by: ashok1


    IBM XL C/C++ Enterprise Edition V8.0 for AIX
    Version: 08.00.0000.0015

    Do I need to install any additional patch (OS and/or compiler)? Any comments/suggestion..

    sample program:
    $> cat 2.cpp
    #include <iostream>
    template <typename T>
    class base
    {
    public:
    typedef T value_type;
    void erase(T t);
    void erase(T t, T u);
    };

    template <typename T>
    void base<T>::erase(T x)
    {
    std::cerr << "base::erase(T x)\n";
    }

    template <typename T>
    void base<T>::erase(T x, T y)
    {
    std::cerr << "base::erase(T x, T y)\n"; }

    template <typename T>
    class derived : public base<T>
    {
    public:
    typedef base<T> Base;
    typedef typename Base::value_type value_type;
    using Base::erase;
    void erase(value_type x);
    };

    template <typename T>
    void derived<T>::erase(value_type x)
    {
    std::cerr << "derived::erase(int x)\n"; }

    class A : private derived<int>
    {
    public:
    typedef derived<int> base_type;
    void Test()
    {
    base_type::erase(42);
    }
    };

    int main()
    {
    A().Test();
    }

    ********
    Error
    ********
    $> xlC 2.cpp -o 2
    "2.cpp", line 46.9: 1540-0219 (S) The call to "base_type::erase" has no best match.
    "2.cpp", line 46.9: 1540-1230 (I) Argument number 1 is the implicit "this" argument.
    "2.cpp", line 46.26: 1540-1229 (I) Argument number 2 is an rvalue of type "int".
    "2.cpp", line 13.6: 1540-1202 (I) No candidate is better than "base<int>::erase(int)".
    "2.cpp", line 46.9: 1540-1231 (I) The conversion from argument number 1 to "derived<int> &" uses "a base class conversion".
    "2.cpp", line 46.26: 1540-1231 (I) The conversion from argument number 2 to "int" uses "the identity conversion".
    "2.cpp", line 35.6: 1540-1202 (I) No candidate is better than "derived<int>::erase(value_type)".
    "2.cpp", line 46.9: 1540-1231 (I) The conversion from argument number 1 to "derived<int> &" uses "a base class conversion".
    "2.cpp", line 46.26: 1540-1231 (I) The conversion from argument number 2 to "int" uses "the identity conversion".

    #AIX-Forum


  • 2.  Re: compilation error: AIX 5.3 and XL C/C++ Enterprise Edition V8.0

    Posted Mon September 03, 2007 09:08 AM

    Originally posted by: MichaelAM


    I am an old C hacker myself, and never did much with C++. However, I suspect it is your constant value as argument (42) that the compiler is complaining about.

    What is this program supposed to accomplish? "erase" a constant seems useless at best, and very likely would be the cause of strange side effects in a regular program.

    A regular C compiler should complain if I later that the address of an inlined constant and try to modify that constant - as the compiler may be doing optimalization and using the inline constant several times - under the assumption that it is a constant!

    But, that is just an idea!
    #AIX-Forum