1 .. title:: clang-tidy - portability-template-virtual-member-function
3 portability-template-virtual-member-function
4 ============================================
6 Finds cases when an uninstantiated virtual member function in a template class causes
7 cross-compiler incompatibility.
9 Upon instantiating a template class, non-virtual member functions don't have to be
10 instantiated unless they are used. Virtual member function instantiation on the other hand
11 is unspecified and depends on the implementation of the compiler.
13 In the following snippets the virtual member function is not instantiated by GCC and Clang,
14 but it is instantiated by MSVC, so while the snippet is accepted by the former compilers,
15 it is rejected by the latter.
20 struct CrossPlatformError {
21 virtual ~CrossPlatformError() = default;
25 virtual void unused() {
31 CrossPlatformError<int>::used();
35 Cross-platform projects that need to support MSVC on Windows might see compiler errors
36 because certain virtual member functions are instantiated, which are not instantiated
37 by other compilers on other platforms. This check highlights such virtual member functions.