Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
9 changes: 1 addition & 8 deletions modules/strong_ptr.cppm
Original file line number Diff line number Diff line change
Expand Up @@ -284,14 +284,7 @@ struct rc
if (p_object != nullptr) {
// Cast back into the original rc<T> type and ...
auto const* obj = static_cast<rc<T> 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<ref_info>) {
obj->m_info.~ref_info();
}
obj->~rc<T>();
}
// Return size for future deallocation
return sizeof(rc<T>);
Expand Down
1 change: 1 addition & 0 deletions test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down