From 87bc96c688a04010fabdbedf9aa60ba026f4ba6c Mon Sep 17 00:00:00 2001 From: Khalil Estell Date: Tue, 23 Dec 2025 12:52:05 -0800 Subject: [PATCH 1/2] :bug: (patch) Add exceptions an no-rtti ABI flags libhal projects use the no-rtti ABI flag to disable RTTI for all objects except for exceptions. Currently strong_ptr enables this ABI by not specifying that its disabled preventing its usage in programs with RTTI disabled. --- CMakeLists.txt | 13 +++++++++++++ test_package/CMakeLists.txt | 1 + 2 files changed, 14 insertions(+) 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/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 From 89e73e1f7aa604946030ef043fd856be3b13815f Mon Sep 17 00:00:00 2001 From: Khalil Estell Date: Tue, 23 Dec 2025 13:05:25 -0800 Subject: [PATCH 2/2] Fix incorrect rc destruction --- modules/strong_ptr.cppm | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) 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);