🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.g++.bug
Article #1087

Re: template with const bug?

#1087
From: Mike Stump
Date: Fri, 06 Nov 1992 08:14
93 lines
2331 bytes
This problem has been fixed, and should not exist in the next release
of gcc.

> Message-Id: <199207030837.AA14425@teal.csn.org>
> From: Steve Sullivan <sullivan@csn.org>
> To: bug-gcc@prep.ai.mit.edu
> Date: Fri, 3 Jul 1992 02:37:19 -0600

> It appears that gcc 2.2.2 is not recognizing
> "const" with "template" properly.

> For example, Listing A (below) produces:
>   > g++ -c testd.cc
>   testd.cc: In function `int  main ()':
>   testd.cc:9: template for method `print' doesn't match any in class `QI<int>'
>   Exit 1

>   > gcc -v
>   Reading specs from /usr/local/lib/gcc-lib/sparc-sun-sunos4.1/2.2.2/specs
>   gcc version 2.2.2

> But after removing the "const" on line 5 it
> compiles successfully.  My understanding of
> C++, however, is that the "const" is required
> on _both_ the declaration and definition of
> the function (both lines 5 and 18).
> See Lippman, page 231 bottom.

> Also, after removing the template code,
> as in Listing B, it compiles successfully.

> What gives?
> Many thanks for the help ...

> Steve Sullivan
> sullivan@csn.org



> ======== Listing A start. cut here =============
> template <class T>
> class QI {
> public:
>   QI(); 
>   void print() const;             // line 5
> private:
>   T item;
>   QI *next;
>   };



> template <class T>
> QI<T>::QI() {}


> template <class T>
> void QI<T>::print() const {};     // line 18


> main () {
>    QI<int> alpha();
>    }
> ======== Listing A end. cut here =============





> ======== Listing B start. cut here =============
> class QI {
> public:
>   QI(); 
>   void print() const;          // line 4
> private:
>   int item;
>   QI *next;
>   };




> QI::QI() {}



> void QI::print() const {};   // line 17


> main () {
>    QI alpha();
>    }
> ======== Listing B end. cut here =============
Technical Details
Message-ID: <9211060814.AA00623@cygnus.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!ogicse!emory!wupost!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!cygnus.com!mrs

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!ogicse!emory!wupost!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!cygnus.com!mrs
From: mrs@cygnus.com (Mike Stump)
Newsgroups: gnu.g++.bug
Subject: Re:  template with const bug?
Message-ID: <9211060814.AA00623@cygnus.com>
Date: 6 Nov 92 08:14:39 GMT
Article-I.D.: cygnus.9211060814.AA00623
Sender: gnulists@ai.mit.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 93
Approved: bug-g++@prep.ai.mit.edu