public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Oleg Krivosheev <kriol@fnal.gov>
To: Jason Merrill <jason@cygnus.com>
Cc: Oleg Krivosheev <kriol@fnal.gov>, egcs@cygnus.com
Subject: Re: something wrong with template instantiation mechanics
Date: Fri, 10 Oct 1997 17:21:00 -0000	[thread overview]
Message-ID: <Pine.GSO.3.96.971010135321.7378B-100000@drabble> (raw)
In-Reply-To: <u9201tv4q4.fsf@yorick.cygnus.com>

hi,

On Fri, 10 Oct 1997, Jason Merrill wrote:

> >>>>> Oleg Krivosheev <kriol@fnal.gov> writes:
> 
> > after reading CD2 and thinking a bit i still
> > believe this is a bug:
> 
> >   14.8.3  Overload resolution                                [temp.over]
> 
> > ..
> >   For each function template, if the  argument
> >   deduction succeeds, the deduced template-arguments are used to instan-
> >   tiate a single function template specialization which is added to  the
> >   candidate  functions set to be used in overload resolution.
> > ..
> 
> > well, lloks like egcs deduces templates argument right,
> 
> Yes.
> 
> > then it properly did everload resolution and
> > choose template version of abs
> 
> No.  It chose the non-template abs declared by the line
> 
>     friend numT            abs( const TVector3D<numT>& );      
> 

hmm...
ok, reading again CD2:

  14.5.3  Friends                                          [temp.friend]

1 A friend function of a class template can be a function template or an
  ordinary (non-template) function.  [Example:
          template<class T> class task {
              // ...
              friend void next_time();
              friend task<T>* preempt(task<T>*);
              friend task* prmt(task*);           // task is task<T>
              friend class task<int>;
              // ...
          };
  Here,  next_time()  and  task<int> become friends of all task classes,
  and each task has appropriately typed functions preempt()  and  prmt()
  as  friends.   The preempt functions might be defined as a template as
  follows
          template<class T> task<T>* preempt(task<T>* t) { /* ... */ }
   --end example]


it looks for me that i'v declared/defined 
abs and op+ in exactly the same manner as proposed in CD2.
It worked just fine with egcs-2.90.10, so it's regression, IMO
Just in case, i've enclosed below very small test case for op+:

template <class T> class X {
  public:
    X( T );
    X( const X<T>& );
    ~X();
    friend X<T> operator+( const X<T>&, const X<T>& );
  private:
    T t_;
};

template <class T>
X<T>::
X( T t ):
  t_(t) {
}

template <class T>
X<T>::
X( const X<T>& x ):
  t_(x.t_) {
}

template <class T>
X<T>::
~X() {
}

template <class T> X<T>
operator+( const X<T>& a, const X<T>& b ) {
  return X<T>( a.t_ + b.t_ );
}

main( void ) {
}

void
dummy( void ) {
  X<int> x( 1 );
  X<int> y( 2 );

  x = x+y;
}



  reply	other threads:[~1997-10-10 17:21 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <3439FE5B.53F1D3CC.cygnus.egcs@msu.ru>
1997-10-07  3:15 ` AIX & shared libstdc++ Jason Merrill
1997-10-07  3:48   ` Andrey Slepuhin
1997-10-09  9:26   ` Andrey Slepuhin
1997-10-09 15:14     ` Ian Lance Taylor
1997-10-13  5:05       ` Andrey Slepuhin
1997-10-09 16:31     ` something wrong with template instantiation mechanics Oleg Krivosheev
1997-10-10  8:51       ` Joe Buck
1997-10-10  8:51         ` Oleg Krivosheev
1997-10-10  8:51           ` Oleg Krivosheev
     [not found]           ` <Pine.GSO.3.96.971009232426.6908A-100000.cygnus.egcs@drabble>
1997-10-10 11:44             ` Jason Merrill
1997-10-10 17:21               ` Oleg Krivosheev [this message]
1997-10-10 17:19                 ` Jason Merrill
1997-10-10 11:46         ` Oleg Krivosheev
1997-10-10 20:46           ` Alexandre Oliva
1997-10-10  8:51       ` Joe Buck
     [not found] <orbu0tza3m.fsf@sunsite.dcc.unicamp.br>
1997-10-13 13:41 ` Oleg Krivosheev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.GSO.3.96.971010135321.7378B-100000@drabble \
    --to=kriol@fnal.gov \
    --cc=egcs@cygnus.com \
    --cc=jason@cygnus.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).