How can I detect whether thread sanitizer has been turned on for a build using gcc 5? Neither one of the two between __has_feature(thread_sanitizer)
nor __SANITIZE_THREAD__
work
#include <iostream>
using std::cout;
using std::endl;
int main() {
cout << __has_feature(thread_sanitizer) << endl;
cout << __SANITIZE_THREAD__ << endl;
}
https://wandbox.org/permlink/t5qYme4Whyj54aYV. This compiles on the versions of clang that have thread sanitizer; but not for some gcc versions (5 in particular)
Both the feature check and the __SANITIZE_THREAD__
macro are useful in detecting when the thread sanitizer has been turned on so tests can suppress false-negatives (eg. when thread sanitizer catches a bug that's not actually a data race) See this for more