🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #2137

Templates and Undefined Functions.

#2137
From: Harvey Rook
Date: Fri, 06 Oct 1995 15:04
42 lines
1852 bytes
I friend of mine ran into a rather odd situation today. We found the 
solution, but now I'm trying to find out what the standard would says about 
this
situation.

A long time ago we copied some code from a random library. Inside this code 
was something similar to:

 template <class t> class FooClass
       {
 public:
       t *FooReturn()
               {
               return (t *)UndefinedFunc();
               };
       };

Unfortunatly we forgot to copy UndefinedFunc() and its prototype along with 
the  FooClass.

As chance would have it, we never created an instance of FooClass.

On compilers A and B, FooClass compiled fine. However compiler C complained 
that FooClass called the undefined function, UndefinedFunc().

What does the standard say about templates and inline functions that are 
never used? Do they have to contain completly valid code? Or can they be 
ignored? Which compiler is right?

BTW, our solution to get the code to compile with compiler C was to simply 
delete  FooClass.

Harvey Rook
harveyr@linkage.com
"Any species that has the technology to destroy itsself, should." -Mike 
Burns


[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID: <30753E6F@Toronto.LinkAge.com>
Path: arc1-ca.pugleaf.net!engnews2.Eng.Sun.COM!taumet!clamage

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!engnews2.Eng.Sun.COM!taumet!clamage
From: Harvey Rook <harveyr@LinkAge.com>
Newsgroups: comp.std.c++
Subject: Templates and Undefined Functions.
Date: 6 Oct 1995 15:04:04 GMT
Organization: ?
Approved: clamage@eng.sun.com (comp.std.c++)
Message-ID: <30753E6F@Toronto.LinkAge.com>
NNTP-Posting-Host: taumet.eng.sun.com
Content-Type: text
Encoding: 38 TEXT
X-Mailer: Microsoft Mail V3.0
Content-Length: 1125
X-Lines: 38
Originator: clamage@taumet