You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@stdcxx.apache.org by Martin Sebor <se...@roguewave.com> on 2006/02/14 17:53:11 UTC

Re: Errors compiling examples - Sun studio 11

Dipak Bapatla wrote:
> Hi,
>    
>   The same error shows up with around three or four examples. 

The error is obviously bogus. It says there is an ambiguity between

     __rb_tree::_C_make_iter (__rw_rb_tree_node*)

and

     __rb_tree::_C_make_iter (const __rw_rb_tree_node*) const

There is no ambiguity between the two and I'm not seeing any errors
in my build. What exactly is the CC version you are using? Mine is

     $ CC -V
     CC: Sun C++ 5.8 2005/10/13

Martin

Re: Errors compiling examples - Sun studio 11

Posted by Martin Sebor <se...@roguewave.com>.
Dipak Bapatla wrote:
> Actually I tried a test case with using string which should use
> templates and it works fine. Anyhow, I compiled the code below and it
> compiles fine.

Great! I created STDCXX-145 as a reminder for us to incorporate your
patch on the trunk: http://issues.apache.org/jira/browse/STDCXX-145.

Martin

Re: Errors compiling examples - Sun studio 11

Posted by Dipak Bapatla <de...@sbcglobal.net>.
Actually I tried a test case with using string which should use templates and it works fine. Anyhow, I compiled the code below and it compiles fine.
   
  thanks,
  Dipak

Martin Sebor <se...@roguewave.com> wrote:
  Dipak Bapatla wrote:
> I have changed the code as follows in the two definitions in _tree.h to
> get the examples to compile.
> const_iterator _C_make_iter (const _C_link_t __node) const {
> return const_iterator (*this, _C_tree_citer (__node));
> }
> 
> to 
> 
> const_iterator _C_make_iter (_C_link_t __node) const {
> return const_iterator (*this, _C_tree_citer (__node));
> }
> 
> Removed the const from the parameter type. 

Okay, I think we're getting somewhere. I missed this in the error
message since it expands typedefs but the const is pointless there
since it doesn't do what I suspect the author thought it did (i.e.,
apply to the object type rather than to the pointer).

> 
> It is weird that the compiler complained about the code because I have
> the test program below and it works fine as expected.

The bug is probably more subtle than that. Your program doesn't
involve templates. Does the more complicated test case below
compile?

Martin

template struct A { typedef T* P; };

template 
struct B {
typedef typename A::P P;

void foo (P) { }
void foo (const P) const { }

void bar () { foo ((P)0); }
void bar () const { foo ((P)0); }
};

template 
struct C {
B b;

void bar () { b.bar (); }
void bar () const { b.bar (); }
};

int main () {
C c;
c.bar ();

const C d = C();
d.bar ();
}
  


Re: Errors compiling examples - Sun studio 11

Posted by Martin Sebor <se...@roguewave.com>.
Dipak Bapatla wrote:
> I have changed the code as follows in the two definitions in _tree.h to
> get the examples to compile.
>       const_iterator _C_make_iter (const _C_link_t __node) const {
>         return const_iterator (*this, _C_tree_citer (__node));
>     }
> 
>       to 
>    
>       const_iterator _C_make_iter (_C_link_t __node) const {
>         return const_iterator (*this, _C_tree_citer (__node));
>     }
> 
>  Removed the const from the parameter type. 

Okay, I think we're getting somewhere. I missed this in the error
message since it expands typedefs but the const is pointless there
since it doesn't do what I suspect the author thought it did (i.e.,
apply to the object type rather than to the pointer).

>    
>   It is weird that the compiler complained about the code because I have
> the test program below and it works fine as expected.

The bug is probably more subtle than that. Your program doesn't
involve templates. Does the more complicated test case below
compile?

Martin

template <class T> struct A { typedef T* P; };

template <class T>
struct B {
     typedef typename A<T>::P P;

     void foo (P) { }
     void foo (const P) const { }

     void bar () { foo ((P)0); }
     void bar () const { foo ((P)0); }
};

template <class T>
struct C {
     B<T> b;

     void bar () { b.bar (); }
     void bar () const { b.bar (); }
};

int main () {
     C<int> c;
     c.bar ();

     const C<int> d = C<int>();
     d.bar ();
}

Re: Errors compiling examples - Sun studio 11

Posted by Dipak Bapatla <de...@sbcglobal.net>.
I have changed the code as follows in the two definitions in _tree.h to get the examples to compile.
      const_iterator _C_make_iter (const _C_link_t __node) const {
        return const_iterator (*this, _C_tree_citer (__node));
    }

      to 
   
      const_iterator _C_make_iter (_C_link_t __node) const {
        return const_iterator (*this, _C_tree_citer (__node));
    }

 Removed the const from the parameter type. 
   
  It is weird that the compiler complained about the code because I have the test program below and it works fine as expected.
   
  #include <iostream>

  class Hello {
   public:
   int num(int a) { return 1; };
   int num(const int a) const { return 3; }
};
   
  int main(int argc, char** argv)
{
  Hello a;
  const Hello b = a;
  int k=3;
  std::cout << a.num(k) << std::endl;
  std::cout << b.num(k) << std::endl;
}

  macms01$ ./testit
1
3
   
  Martin Sebor <se...@roguewave.com> wrote:
  Dipak Bapatla wrote:
> CC: Sun C++ 5.8 Patch 121017-01 2005/12/11

So it looks like we have the vanilla 5.8 and you are have a patched
version of the same. I don't think I can get this version installed
here anytime soon to reduce the error to a small enough test case
to put together and test a workaround for you but I can suggest one.

Rename the const overload of _C_make_iter to _C_make_const_iter (or
something similarly unique), and replace all calls to it (i.e., all
calls from other __rw_tree const member functions) with those to the
renamed function.

Martin


> 
> Martin Sebor wrote: Dipak Bapatla wrote:
> 
>>Hi,
>>
>>The same error shows up with around three or four examples. 
> 
> 
> The error is obviously bogus. It says there is an ambiguity between
> 
> __rb_tree::_C_make_iter (__rw_rb_tree_node*)
> 
> and
> 
> __rb_tree::_C_make_iter (const __rw_rb_tree_node*) const
> 
> There is no ambiguity between the two and I'm not seeing any errors
> in my build. What exactly is the CC version you are using? Mine is
> 
> $ CC -V
> CC: Sun C++ 5.8 2005/10/13
> 
> Martin
> 
> 
> 

  


Re: Errors compiling examples - Sun studio 11

Posted by Martin Sebor <se...@roguewave.com>.
Dipak Bapatla wrote:
> CC: Sun C++ 5.8 Patch 121017-01 2005/12/11

So it looks like we have the vanilla 5.8 and you are have a patched
version of the same. I don't think I can get this version installed
here anytime soon to reduce the error to a small enough test case
to put together and test a workaround for you but I can suggest one.

Rename the const overload of _C_make_iter to _C_make_const_iter (or
something similarly unique), and replace all calls to it (i.e., all
calls from other __rw_tree const member functions) with those to the
renamed function.

Martin


> 
> Martin Sebor <se...@roguewave.com> wrote:  Dipak Bapatla wrote:
> 
>>Hi,
>>
>>The same error shows up with around three or four examples. 
> 
> 
> The error is obviously bogus. It says there is an ambiguity between
> 
> __rb_tree::_C_make_iter (__rw_rb_tree_node*)
> 
> and
> 
> __rb_tree::_C_make_iter (const __rw_rb_tree_node*) const
> 
> There is no ambiguity between the two and I'm not seeing any errors
> in my build. What exactly is the CC version you are using? Mine is
> 
> $ CC -V
> CC: Sun C++ 5.8 2005/10/13
> 
> Martin
> 
> 
> 


Re: Errors compiling examples - Sun studio 11

Posted by Dipak Bapatla <de...@sbcglobal.net>.
CC: Sun C++ 5.8 Patch 121017-01 2005/12/11

Martin Sebor <se...@roguewave.com> wrote:  Dipak Bapatla wrote:
> Hi,
> 
> The same error shows up with around three or four examples. 

The error is obviously bogus. It says there is an ambiguity between

__rb_tree::_C_make_iter (__rw_rb_tree_node*)

and

__rb_tree::_C_make_iter (const __rw_rb_tree_node*) const

There is no ambiguity between the two and I'm not seeing any errors
in my build. What exactly is the CC version you are using? Mine is

$ CC -V
CC: Sun C++ 5.8 2005/10/13

Martin