Bug 8 - friend template function declaration within template class
Summary: friend template function declaration within template class
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: unknown
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2000-02-28 01:56 UTC by martin
Modified: 2003-07-25 17:33 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description martin 2000-02-28 01:56:00 UTC
[Original report in <200002211845.MAA00490@camembert.cs.utexas.edu>]

Release:
unknown

Environment:
System: Linux mira 2.3.48 #4 Sun Feb 27 23:26:02 CET 2000 i586 unknown
Architecture: i586

How-To-Repeat:
// This program demonstrates what I believe is a bug with
// GCC-2.95.2/SPARC (g++).
//
// If a template function is declared within a template class, and the
// template parameters are those of the class, (superfluously)
// specifying the template parameters in the function declaration,
// e.g., fu< bar >() causes an error when the template function is
// instantiated. 

#include <valarray>
#include <iterator>
namespace std
{
template <class _Category, class _Tp, class _Distance = ptrdiff_t,
          class _Pointer = _Tp*, class _Reference = _Tp&>
struct iterator {
  typedef _Category  iterator_category;
  typedef _Tp        value_type;
  typedef _Distance  difference_type;
  typedef _Pointer   pointer;
  typedef _Reference reference;
};
}

template< typename T , typename C > 
class SliceIter ;
// out-of-class declaration of friend function - superfluous for GCC,
// needed for KCC 3.4g
template< typename T , typename C > 
bool 
operator==( SliceIter< T , C > const & , SliceIter< T , C > const & ) ;

// friendship granting class definition.
template< typename T , typename C > 
class SliceIter
  : public std::iterator< std::random_access_iterator_tag , T >
{
private :
  int curr ;

  friend bool 
  operator==< T , C >( SliceIter< T , C > const & , SliceIter< T , C > const & ) ; 
} ;

template< typename T , typename C >
bool 
operator==( SliceIter< T , C > const & p , SliceIter< T , C > const & q )
{
  return( p.curr == q.curr ) ;
}


int
main( void )
{
  SliceIter< int , std::valarray< int > > sa ;
  SliceIter< int , std::valarray< int > > sb ;

  return( sa == sb ) ;
}
Comment 1 Martin v. Loewis 2000-03-08 23:00:57 UTC
State-Changed-From-To: open->analyzed
State-Changed-Why: Confirmed to be a bug
Comment 2 Martin v. Loewis 2000-03-09 07:00:57 UTC
From: loewis@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org, martin@loewis.home.cs.tu-berlin.de,
  nobody@gcc.gnu.org
Cc:  
Subject: Re: c++/8
Date: 9 Mar 2000 07:00:57 -0000

 Old Synopsis: [not accepted] friend template function declaration within template class
 New Synopsis: friend template function declaration within template class
 
 State-Changed-From-To: open->analyzed
 State-Changed-By: loewis
 State-Changed-When: Wed Mar  8 23:00:57 2000
 State-Changed-Why:
     Confirmed to be a bug
 
 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=8&database=gcc

Comment 3 Jason Merrill 2000-08-08 17:36:46 UTC
State-Changed-From-To: analyzed-closed
State-Changed-Why: Fixed with
2000-08-08  Jason Merrill  <jason@redhat.com>

	* pt.c (tsubst_aggr_type): Bail if creating the argvec fails.
	(tsubst_template_arg_vector): Likewise.
Comment 5 GCC Commits 2003-07-15 16:56:53 UTC
Subject: Bug 8

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	mmitchel@gcc.gnu.org	2003-07-15 16:56:50

Modified files:
	gcc            : ChangeLog dbxout.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/debug: debug8.C 

Log message:
	PR debug/11473
	* dbxout.c (dbxout_type): Use TYPE_SIZE to determine the sizes of
	base classes.
	
	PR debug/11473
	* g++.dg/debug/debug8.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.515&r2=2.516
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/dbxout.c.diff?cvsroot=gcc&r1=1.154&r2=1.155
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.2880&r2=1.2881
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/debug/debug8.C.diff?cvsroot=gcc&r1=1.1&r2=1.2