Nous utilisons le code suivant pour déterminer si -fsanitize = adresse a été spécifié au moment de la compilation pour clang et gcc. Comment déterminer si -fsanitize = undefined a été spécifié?Comment puis-je déterminer si UBSAN a été compilé en utilisant clang ou gcc?
bool isSanitized = false;
#if defined(__has_feature)
#if __has_feature(address_sanitizer)
isSanitized = true;
#endif
#elif defined(__SANITIZE_ADDRESS__)
isSanitized = true;
#endif
Vous pouvez vérifier cela http://stackoverflow.com/questions/38719560/-there-a-way-to-store-clang-compile-time-flags-in-the-output-binary – xhamr
Cela ne marche pas t fonctionnent de la même manière que la détection ASAN. –