From b8268467da3b5caa95d9a7058d05c3f94ac09465 Mon Sep 17 00:00:00 2001 From: Brett Date: Tue, 18 Jun 2024 14:01:31 -0400 Subject: [PATCH] call destructor on pop, needs on pop_bytes() --- CMakeLists.txt | 2 +- include/blt/gp/stack.h | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 283b44d..11d97b0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.25) -project(blt-gp VERSION 0.0.19) +project(blt-gp VERSION 0.0.20) option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF) option(ENABLE_UBSAN "Enable the ub sanitizer" OFF) diff --git a/include/blt/gp/stack.h b/include/blt/gp/stack.h index dfc6d25..f899548 100644 --- a/include/blt/gp/stack.h +++ b/include/blt/gp/stack.h @@ -54,7 +54,10 @@ namespace blt::gp if (head->used_bytes_in_block() < static_cast(aligned_size())) throw std::runtime_error((std::string("Mismatched Types! Not enough space left in block! Bytes: ") += std::to_string( head->used_bytes_in_block()) += " Size: " + std::to_string(sizeof(T))).c_str()); + // make copy T t = *reinterpret_cast(head->metadata.offset - TYPE_SIZE); + // call destructor + reinterpret_cast(head->metadata.offset - TYPE_SIZE)->~T(); head->metadata.offset -= TYPE_SIZE; if (head->used_bytes_in_block() == 0) {