[clang-tidy] portability-template-virtual-member-function triggers on constexpr member accesses #132521

@apple1417

Description

I'm not really sure this is a bug, but it's a weird edge case that felt worth bringing up.

#include <fstream>
void test(void




    
) {
    std::ofstream stream{"dummy", std::wofstream::trunc};

Note that the mode is set using std::wofstream, not std::ofstream.

Running clang-tidy 20.1.0 on a Windows system gives me the following warning:

PS P:\test> clang-tidy .\test.cpp --checks=portability-template-virtual-member-function
Error while trying to load a compilation database:
Could not auto-detect compilation database for file ".\test.cpp"
No compilation database found in P:\test\. or any parent directory
fixed-compilation-database: Error while opening fixed database: no such file or directory
json-compilation-database: Error while opening JSON database: no such file or directory
Running without flags.
32 warnings generated.
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.42.34433\include\fstream:283:24: warning: unspecified virtual member function instantiation; the virtual member function is not instantiated but it might be with a different compiler [portability-template-virtual-member-function]
  283 |     __CLR_OR_THIS_CALL ~basic_ofstream() noexcept override {}
      |                        ^
P:\test\.\test.cpp:4:40: note: template instantiated here
    4 |     std::ofstream stream{"dummy", std::wofstream::trunc};
      |                                        ^
Suppressed 31 warnings (31 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.

This feels a bit unintuitive to me, since I'm never actually using a std::wofstream object, it doesn't feel like the best diagnostic.