[Insight-developers] Subtle Error in defining inline functions with explicit instantiation

Hans Johnson hans-johnson at uiowa.edu
Sun Oct 1 14:29:19 EDT 2006


Hello Developers,

I have found a subtle problem in the way some inline functions are declared
and defined when explicit instantiation is used.  This problem only occurs
when an inline function is declared in the ".h" file and defined in the
".txx" file and explicit instantiation is used.

The explicit instantiation mechanism works by intervening between the class
declaration and the ".txx" files definitions for the types that are
requested for explicit instantiation.  The problem is that the inline
functions are declared but not defined for explicitly instantiated types
after the types are built.  It seems that the code is actually compiled
correctly, because during the build of the explicitly instantiated types,
the definitions are available, but during subsequent calls, those types will
not be defined.

I think that the correct solution would be to put inline function
definitions and declarations in the ".h" files.  I have done some limited
testing, and this does fix the problem.  A quick survey indicates that there
are only about 42 such instances (grep -r "inline.*;$" *) that would need to
be fixed.

If I do not hear reasons to the contrary, I will be making these changes
early this week.

Thanks,
Hans




More information about the Insight-developers mailing list