This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

c++/2656: template instantiation problem with gcc 2.95.2



>Number:         2656
>Category:       c++
>Synopsis:       template instantiation problem with gcc 2.95.2
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Thu Apr 26 10:46:01 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     ik.yoo@morganstanley.com
>Release:        gcc version 2.95.2 19991024 (release)
>Organization:
>Environment:
Red Hat Linux release 6.2 (Zoot)
Kernel 2.2.14-5.0smp on a 4-processor i686
>Description:
Compiling code below gives the following error. It compiles
ok under 2.91.66 (and other c++ compilers). Also, if I
comment out either of the two operator== declaration from
FooBase, it compiles fine on 2.95.2. 

foo.C: In instantiation of `FooBase<double>':
foo.C:29:   instantiated from `Foo<double>'
foo.C:29:   instantiated from here
foo.C:10: invalid use of undefined type `class FooBase<double>'
foo.C:12: forward declaration of `class FooBase<double>'
>How-To-Repeat:
Detach foo.C and compile as follows:

g++ -c foo.C
>Fix:
None so far.
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="foo.C"
Content-Disposition: inline; filename="foo.C"

template <class Type> class FooBase;

template <class Type>
int operator==(const FooBase<Type>&, const Type&);

template <class Type>
class FooBase
{
public:
  // commenting out either of the next 2 lines will compile this
  // example under 2.95.2
  friend int operator== <> (const FooBase<Type>&, const Type&);
  int operator==(const FooBase<Type>&) const {};
};

template <class Type>
int operator== (const FooBase<Type>&, const Type&)
{
  return 0;
}

template <class Type>
class Foo : public FooBase<Type>
{
}; 

template <class Type> class Bar;

template <>
class Bar<double> : public Foo<double>
{
};


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]