From 9416d8ab002d53842fdedd5cf968d13a005aaf54 Mon Sep 17 00:00:00 2001 From: Arendelle Date: Mon, 17 Nov 2025 16:09:38 +0800 Subject: [PATCH 1/2] bugfix fast_io::list --- include/fast_io_dsal/impl/list.h | 2 +- .../0002.list/list_init_rvalue.cc | 37 +++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 tests/0026.container/0002.list/list_init_rvalue.cc diff --git a/include/fast_io_dsal/impl/list.h b/include/fast_io_dsal/impl/list.h index e58c566b..7022edcb 100644 --- a/include/fast_io_dsal/impl/list.h +++ b/include/fast_io_dsal/impl/list.h @@ -457,7 +457,7 @@ class list } else { - typed_allocator_type::deallocate(ptr, 1); + typed_allocator_type::deallocate(ptr); } } }; diff --git a/tests/0026.container/0002.list/list_init_rvalue.cc b/tests/0026.container/0002.list/list_init_rvalue.cc new file mode 100644 index 00000000..f598c45a --- /dev/null +++ b/tests/0026.container/0002.list/list_init_rvalue.cc @@ -0,0 +1,37 @@ +#include +#include + +struct X { + X() { + ::fast_io::println("default"); + } + + X(X const&) { + ::fast_io::println("copy"); + } + + X(X&&) { + ::fast_io::println("move"); + } + + ~X() { + ::fast_io::println("destruct"); + } + + X& operator=(X const&) { + ::fast_io::println("copy assign"); + return *this; + } + + X& operator=(X&&) { + ::fast_io::println("move assign"); + return *this; + } +}; + +int main() { + // TODO copy X here, can it be fixed? (caused by std::initilizer_list) + ::fast_io::list const l1{X{}}; + + return 0; +} From e2c52debe5c279fb5917cb020defb1f0beb78775 Mon Sep 17 00:00:00 2001 From: Arendelle Date: Mon, 17 Nov 2025 22:03:46 +0800 Subject: [PATCH 2/2] Drop deallocate, use deallocate_n instead --- include/fast_io_dsal/impl/list.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/fast_io_dsal/impl/list.h b/include/fast_io_dsal/impl/list.h index 7022edcb..bb915424 100644 --- a/include/fast_io_dsal/impl/list.h +++ b/include/fast_io_dsal/impl/list.h @@ -457,7 +457,7 @@ class list } else { - typed_allocator_type::deallocate(ptr); + typed_allocator_type::deallocate_n(ptr, 1); } } };