LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 445 - [llvmg++] not enough templates are instantiated
Summary: [llvmg++] not enough templates are instantiated
Status: RESOLVED FIXED
Alias: None
Product: tools
Classification: Unclassified
Component: llvm-g++ (show other bugs)
Version: 1.3
Hardware: All All
: P normal
Assignee: Chris Lattner
URL:
Keywords: compile-fail
Depends on:
Blocks:
 
Reported: 2004-09-27 21:15 PDT by Chris Lattner
Modified: 2010-02-22 12:43 PST (History)
1 user (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Lattner 2004-09-27 21:15:47 PDT
In the testcase below (reduced from llvm-llvm) does not ever emit an
instantiation of callDefaultCtor<Pass> to the LLVM file, resulting in missing
symbols.  The #include of <string> and use of .empty() are required to trigger
this failure.

-----------

struct Pass {} ;
template<typename PassName>
Pass *callDefaultCtor() { return new PassName(); }

void foo(Pass *(*C)());

#include <string>

bool foo(std::string &X) {
  return X.empty();
}

void baz() { foo(callDefaultCtor<Pass>); }
Comment 1 Chris Lattner 2004-09-27 21:38:41 PDT
Here is a reduced testcase.  Note that marking callDefaultCtor 'inline' causes
it to be emitted! *boggle*

-----

struct Pass {};

template<typename PassName>
Pass *callDefaultCtor() { return new Pass(); }

void foo(Pass *(*C)());

struct basic_string {
  bool empty() const { return true; }
};

bool foo(basic_string &X) {
  return X.empty();
}
void baz() { foo(callDefaultCtor<Pass>); }
Comment 2 Chris Lattner 2004-09-27 22:42:09 PDT
This bug is fixed, patch here:
http://mail.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20040927/018592.html

Testcase here:
http://mail.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20040927/018591.html

It is amazing how all of that quality time spent in GDB ends up with a one line
fix, arg.

-Chris