[cfe-dev] Function Instantiation: Where? Or is it?

Larisse Voufo lvoufo at cs.indiana.edu
Mon Jan 31 08:12:30 PST 2011


Folks --

This has had me puzzled for a while, and I could use an answer asap.
I am implementing concepts in Clang and seem to be missing a crucial piece
of understanding, either of C++, or of Clang.
Basically, I have gotten mostly everything else implemented and working fine
to the extend that I want them to, except for concept members instantiation
(?).

Basic Example:  instantiation.cpp
----------------------

concept B<typename T> {
  void f(int) { }
}

concept_map B<int> {
  void f(int) { }
}

template<typename T>
requires (B<T>)
void func(T a) {
//    f(a);
    f(0);
}

int main(int argc, char **argv)
{
    int i=0;
    func<int>(i);
}

Compilation:  clang++ instantiation.cpp -o example
----------------------
It seems to be failing at link time, with the following error message:

Undefined symbols:
  "__ZN1B1fEi", referenced from:
      __Z4funcIiEvT_ in cc-MXLAc6.o
ld: symbol(s) not found


Any idea? Anyone?
1) At which point are functions marked for instantiation?
2 ) At which point are they instantiated ?
3) If instantiated, why would they not be visible by the linker?

Obviously, concept coverage works, or the template function *func* would
never be defined.
In fact, when all is commented out in the body of *func*, so that it is
empty, the call from the main works flawlessly -- passing compilation.
Un-commenting the call to *f(0)* from *func*, causes the error above.

Please, any idea would be greatly appreciated...

Thanks,

-- Larisse.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110131/3e7ae956/attachment.html>


More information about the cfe-dev mailing list