]> git.ameliathe1st.gay Git - voyage-au-centre-des-fichiers.git/commitdiff
Correction d'un bug: le compilateur avait, de manière peu surprenante, raison
authorAmelia Coutard <eliottulio.coutard@gmail.com>
Fri, 29 Dec 2023 04:01:43 +0000 (05:01 +0100)
committerAmelia Coutard <eliottulio.coutard@gmail.com>
Fri, 29 Dec 2023 04:01:43 +0000 (05:01 +0100)
libcpp/allocator.hpp
libcpp/vector.hpp

index ce976b850463e637a0246c679ff0db21e36cc903..f3987792b11fdfad1987c5f83be1561b029b7be8 100644 (file)
@@ -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;
        }
index 0b217ea8f5205dd8eae19be6bd41a12f4e1715c0..97cd731a3a54a9348a03098b291689153d9c4ace 100644 (file)
@@ -73,10 +73,7 @@ public:
                                capacity_++;
                        } else if (auto new_data =
                                amy::reallocate(allocator, data, capacity_ * amy::byte_size<T>(), capacity_ * 2 * amy::byte_size<T>(), amy::byte_align<T>())) {
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wdangling-pointer"
                                data = (T*)new_data;
-#pragma GCC diagnostic pop
                                capacity_ *= 2;
                        } else {
                                return false;