This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/33878] Pure virtual method body omitted from template



------- Comment #7 from herwig at gdsys dot de  2008-04-01 07:58 -------
(In reply to comment #5)
> (In reply to comment #0)
> > The following stripped down code shows pure virtual method definitions for both
> > a normal base class and a templated base class. To my surprise, the templated
> > class' body is not generated,
> 
> Your example code contains neither a call to TBase<int>::pvMethod (which would
> trigger an implicit instantiation of this function from its template) nor an
> explicit instantiation of either the entire class or of this function.
> Consequently, the compiler doesn't instantiate your template.
> 
> If you intend to call TBase<int>::pvMethod from somewhere where the definition
> of this template is not visible, you need to add an explicit instantiation of
> this function for 'int' as the template arg.
> 
> W.
> 

Wolfgang,

thanks for the clarification. I should have realized it myself, though. I
solved the problem in another way, but out of pure curiosity: How can I
implicitly instatiate this function when it's ought to be called only as a
fallback, in case something went wrong (bad cast, call to half-destroyed object
from another thread, etc.). It needs to be a generic solution as the real
application is a library base template derived from a normal base class used in
a CRTP-manner. I think that is why an implicit instantiation is needed. Or am I
wrong here? Probably I am. :)

Thanks for your reply,
Björn!


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33878


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]