From: Amelia Coutard Date: Fri, 29 Dec 2023 04:01:43 +0000 (+0100) Subject: Correction d'un bug: le compilateur avait, de manière peu surprenante, raison X-Git-Url: https://git.ameliathe1st.gay/?a=commitdiff_plain;h=89754e51a891c05cfe0acca55078c6e3b617c2a3;p=voyage-au-centre-des-fichiers.git Correction d'un bug: le compilateur avait, de manière peu surprenante, raison --- diff --git a/libcpp/allocator.hpp b/libcpp/allocator.hpp index ce976b8..f398779 100644 --- a/libcpp/allocator.hpp +++ b/libcpp/allocator.hpp @@ -66,7 +66,7 @@ concept allocator = requires(T allocator) { // Otherwise, it will return the new pointer to the area. The old one shouldn't be used anymore. // pre: ptr is a pointer to a memory area of size old_size and alignment align allocated by the allocator allocator. // pre: new_size ≥ 1 -void* reallocate(allocator auto allocator, void* ptr, amy::size old_size, amy::size new_size, amy::size align) { +void* reallocate(allocator auto& allocator, void* ptr, amy::size old_size, amy::size new_size, amy::size align) { if (allocator.expand(ptr, old_size, new_size - old_size)) { return ptr; } diff --git a/libcpp/vector.hpp b/libcpp/vector.hpp index 0b217ea..97cd731 100644 --- a/libcpp/vector.hpp +++ b/libcpp/vector.hpp @@ -73,10 +73,7 @@ public: capacity_++; } else if (auto new_data = amy::reallocate(allocator, data, capacity_ * amy::byte_size(), capacity_ * 2 * amy::byte_size(), amy::byte_align())) { -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdangling-pointer" data = (T*)new_data; -#pragma GCC diagnostic pop capacity_ *= 2; } else { return false;