I'm using clang-tidy 10 on a project and it's behaving weirdly on Windows with the MSVC STL. A minimal example is the following:
#include <iostream>
#include <stdexcept>
int main()
{
try {
throw std::runtime_error {"Boom!"};
} catch (...) {
std::cerr << "Unexpected non-exception error!\n";
}
}
If I tell it to include the check bugprone-exception-escape, it tells me an exception may be thrown in function 'main'. However, if I change the line streaming to std::cerr with the following then the check does not cause a complaint:
std::cerr << "Unexpected non-exception error!\n" << std::flush;
I assume the two consecutive stream operations in one statement is the cause of the different behaviour, because the following does raise the problem.
std::cerr << "Unexpected non-exception error!\n";
std::cerr << std::flush;
I noticed clang-tidy does not complain on any of these examples on Linux, at least if I pass -stdlib=libc++. Is there some weird subtlety I'm missing, or is this a bug in clang-tidy and/or MSVC's STL implementation?