From 2e3872c651dc5c0a2c06fa4f0b094617c74fc8bd Mon Sep 17 00:00:00 2001 From: Patrick Urbanke Date: Mon, 4 Dec 2023 20:16:09 +0100 Subject: [PATCH] Fixed -fsanitize=undefined issue; #16, possibly #15 --- include/rfl/internal/get_field_names.hpp | 3 +++ tests/flexbuffers/CMakeLists.txt | 2 +- tests/json/CMakeLists.txt | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/include/rfl/internal/get_field_names.hpp b/include/rfl/internal/get_field_names.hpp index f0e49310..3e197002 100644 --- a/include/rfl/internal/get_field_names.hpp +++ b/include/rfl/internal/get_field_names.hpp @@ -111,6 +111,9 @@ with open("generated_code6.cpp", "w", encoding="utf-8") as codefile: */ template +#if __GNUC__ +[[gnu::no_sanitize_undefined]] +#endif auto get_field_names() { if constexpr (std::is_pointer_v>) { return get_field_names>(); diff --git a/tests/flexbuffers/CMakeLists.txt b/tests/flexbuffers/CMakeLists.txt index 7b0212ad..27e0b29e 100644 --- a/tests/flexbuffers/CMakeLists.txt +++ b/tests/flexbuffers/CMakeLists.txt @@ -48,7 +48,7 @@ add_executable( set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -O2") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++20 -Wall -Wno-sign-compare -Wno-missing-braces -Wno-psabi -pthread -fno-strict-aliasing -fwrapv -O2 -ftemplate-backtrace-limit=0") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++20 -Wall -Wno-sign-compare -Wno-missing-braces -Wno-psabi -pthread -fno-strict-aliasing -fwrapv -O2 -ftemplate-backtrace-limit=0 -fsanitize=undefined") target_link_libraries( reflect-cpp-tests diff --git a/tests/json/CMakeLists.txt b/tests/json/CMakeLists.txt index d0604d43..bbb2adb5 100644 --- a/tests/json/CMakeLists.txt +++ b/tests/json/CMakeLists.txt @@ -72,6 +72,6 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -O2") if (MSVC) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std:c++20") else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++20 -Wall -Wno-sign-compare -Wno-missing-braces -Wno-psabi -pthread -fno-strict-aliasing -fwrapv -O2 -ftemplate-backtrace-limit=0") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++20 -Wall -Wno-sign-compare -Wno-missing-braces -Wno-psabi -pthread -fno-strict-aliasing -fwrapv -O2 -ftemplate-backtrace-limit=0 -fsanitize=undefined") endif()