Bug 26268 - template function implicity instatiated
Summary: template function implicity instatiated
Status: RESOLVED DUPLICATE of bug 26267
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.0.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-02-13 20:26 UTC by Edward Duffy
Modified: 2006-02-13 20:27 UTC (History)
1 user (show)

See Also:
Host: i686-pc-linux-gnu
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 Edward Duffy 2006-02-13 20:26:59 UTC
While compiling:

template<typename T>
struct Type2Type {
   typedef T Type;
};

template<class T>
inline void foo(Type2Type<T> const&) {
   int x = NOT_HERE;
}

int main(int, char *) {
 //  std::cout << "Hello world!" << std::endl;
}

g++ gives an error about NOT_HERE being declared.  Rightly so, but the function `foo' is never called or explicity instantiated, so `foo' should never be compiled.

From "14.7.1 Implicit instantiation" of the ISO C++ standard:
 9. An implementation shall not implicitly instantiate a function template,
    a member template, a non-virtual member function, a member class or a
    static data member of a class template that does not require instantia-
    tion.
Comment 1 Andrew Pinski 2006-02-13 20:27:31 UTC

*** This bug has been marked as a duplicate of 26267 ***