public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c++/7428: Precedence in selecting overloaded operators
@ 2002-07-29  0:26 topiolli
  0 siblings, 0 replies; 3+ messages in thread
From: topiolli @ 2002-07-29  0:26 UTC (permalink / raw)
  To: gcc-gnats


>Number:         7428
>Category:       c++
>Synopsis:       Precedence in selecting overloaded operators
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jul 29 00:26:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     topiolli@ee.oulu.fi
>Release:        g++ (GCC) 3.1.1
>Organization:
>Environment:
SunOS tk3 5.8 Generic_108528-15 sun4u sparc SUNW,Ultra-80
>Description:
I have a template class called SmartPtr that does - guess what.
Since it has a typecast operator, it can be used where a
pointer to the base type is expected. Also, operator == is overloaded
to allow comparison of SmartPtr instances:

template <class T> SmartPtr
{
public:
  operator T* () { return _internalPtr; }
  operator const T* () const { return _internalPtr; }
};

template <class T> bool operator== (const SmartPtr<T>&, const SmartPtr<T>&);

The compiler chokes on this. It cannot figure out whether
it should use the overloaded operator to compare SmartPtrs,
or should it perhaps use the built-in operators for comparing
pointers, because the SmartPtr can be casted to a pointer.
The problem is easily solved by removing the overloaded
operator, but in my mind the overloaded operator should be
the preferred choice as it does not need typecasts.
>How-To-Repeat:

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: c++/7428: Precedence in selecting overloaded operators
@ 2002-07-29  1:58 paolo
  0 siblings, 0 replies; 3+ messages in thread
From: paolo @ 2002-07-29  1:58 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, nobody, paolo, topiolli

Synopsis: Precedence in selecting overloaded operators

Responsible-Changed-From-To: unassigned->paolo
Responsible-Changed-By: paolo
Responsible-Changed-When: Mon Jul 29 01:58:45 2002
Responsible-Changed-Why:
    .
State-Changed-From-To: open->closed
State-Changed-By: paolo
State-Changed-When: Mon Jul 29 01:58:45 2002
State-Changed-Why:
    On submitter's request.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7428


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: c++/7428: Precedence in selecting overloaded operators
@ 2002-07-29  1:26 Topi Maenpaa
  0 siblings, 0 replies; 3+ messages in thread
From: Topi Maenpaa @ 2002-07-29  1:26 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/7428; it has been noted by GNATS.

From: Topi Maenpaa <topiolli@ees2.oulu.fi>
To: gcc-gnats@gcc.gnu.org, <nobody@gcc.gnu.org>
Cc:  
Subject: Re: c++/7428: Precedence in selecting overloaded operators
Date: Mon, 29 Jul 2002 11:22:52 +0300 (EEST)

 You are welcome :) Please don't waste your time with this. I was finally
 able to solve the confusion myself, and it turned out I had just stupidly
 mistaken couple of things.
 
 Good luck.
 
 On 29 Jul 2002 gcc-gnats@gcc.gnu.org wrote:
 
 >Thank you very much for your problem report.
 >It has the internal identification `c++/7428'.
 >The individual assigned to look at your
 >report is: unassigned.
 >
 >>Category:       c++
 >>Responsible:    unassigned
 >>Synopsis:       Precedence in selecting overloaded operators
 >>Arrival-Date:   Mon Jul 29 00:26:00 PDT 2002
 >
 
 -Topi-
  << http://ee.oulu.fi/~topiolli >>
 


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-07-29  8:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-07-29  0:26 c++/7428: Precedence in selecting overloaded operators topiolli
2002-07-29  1:26 Topi Maenpaa
2002-07-29  1:58 paolo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).