From 89754e51a891c05cfe0acca55078c6e3b617c2a3 Mon Sep 17 00:00:00 2001 From: Amelia Coutard Date: Fri, 29 Dec 2023 05:01:43 +0100 Subject: [PATCH] =?utf8?q?Correction=20d'un=20bug:=20le=20compilateur=20av?= =?utf8?q?ait,=20de=20mani=C3=A8re=20peu=20surprenante,=20raison?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- libcpp/allocator.hpp | 2 +- libcpp/vector.hpp | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) 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; -- 2.47.0