diff --git a/CMakeLists.txt b/CMakeLists.txt index 3762cac..560ecaa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,6 +34,16 @@ target_sources(strong_ptr PUBLIC FILES modules/strong_ptr.cppm ) +target_compile_options(strong_ptr PRIVATE + -g + -Werror + -Wno-unused-command-line-argument + -Wall + -Wextra + -Wshadow + -fexceptions + -fno-rtti) + install( TARGETS strong_ptr EXPORT strong_ptr_targets @@ -78,10 +88,13 @@ else() target_compile_options(strong_ptr_unit_test PUBLIC -g -Werror + -Wno-unused-command-line-argument -Wall -Wextra -Wshadow -pedantic + -fexceptions + -fno-rtti ) # Enable ASAN only on non-Windows platforms (Windows doesn't support it) diff --git a/modules/strong_ptr.cppm b/modules/strong_ptr.cppm index 951245e..53757b0 100644 --- a/modules/strong_ptr.cppm +++ b/modules/strong_ptr.cppm @@ -284,14 +284,7 @@ struct rc if (p_object != nullptr) { // Cast back into the original rc type and ... auto const* obj = static_cast const*>(p_object); - // Destruct T. - obj->m_object.~T(); - // Destructor ref_info if its not trivially destructible. In general, this - // should never be the case, but if we do modify ref_info to have a - // non-trivial destructor, this will automatically manage that. - if constexpr (not std::is_trivially_destructible_v) { - obj->m_info.~ref_info(); - } + obj->~rc(); } // Return size for future deallocation return sizeof(rc); diff --git a/test_package/CMakeLists.txt b/test_package/CMakeLists.txt index 28e070f..477fa81 100644 --- a/test_package/CMakeLists.txt +++ b/test_package/CMakeLists.txt @@ -35,6 +35,7 @@ target_sources(${PROJECT_NAME} PUBLIC ) target_include_directories(${PROJECT_NAME} PUBLIC .) target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_23) +target_compile_options(${PROJECT_NAME} PRIVATE -fexceptions -fno-rtti) target_link_libraries(${PROJECT_NAME} PRIVATE strong_ptr) # Always run this custom target by making it depend on ALL