From b314a62c5aa71607c3b82f301743d07349762149 Mon Sep 17 00:00:00 2001 From: Brett Date: Thu, 6 Jun 2024 02:32:19 -0400 Subject: [PATCH] make sure stack is empty after call --- CMakeLists.txt | 2 +- examples/main.cpp | 2 ++ include/blt/gp/program.h | 8 +++++--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 13bb4d2..6461d4f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.25) -project(blt-gp VERSION 0.0.16) +project(blt-gp VERSION 0.0.17) option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF) option(ENABLE_UBSAN "Enable the ub sanitizer" OFF) diff --git a/examples/main.cpp b/examples/main.cpp index c7a04c0..0664472 100644 --- a/examples/main.cpp +++ b/examples/main.cpp @@ -371,6 +371,8 @@ int main() blt::gp::operation silly_op(nyah); std::cout << silly_op(alloc) << std::endl; + + std::cout << "Is empty? " << alloc.empty() << std::endl; // std::cout << std::endl; // diff --git a/include/blt/gp/program.h b/include/blt/gp/program.h index 485ee5f..f313d73 100644 --- a/include/blt/gp/program.h +++ b/include/blt/gp/program.h @@ -115,8 +115,7 @@ namespace blt::gp template inline CurrentArgument& getArgument(stack_allocator& allocator) const { - auto bytes = getByteOffset(); - return allocator.from(bytes); + return allocator.from(getByteOffset()); } template @@ -128,7 +127,10 @@ namespace blt::gp [[nodiscard]] inline Return operator()(stack_allocator& allocator) const { auto seq = std::make_integer_sequence(); - return sequence_to_indices(allocator, seq); + Return ret = sequence_to_indices(allocator, seq); + constexpr auto total_bytes = (stack_allocator::aligned_size() + ...); + allocator.pop_bytes(total_bytes); + return ret; } private: