diff --git a/src/engine/function.cpp b/src/engine/function.cpp index 43b5653b2..26115f1b1 100644 --- a/src/engine/function.cpp +++ b/src/engine/function.cpp @@ -311,14 +311,14 @@ struct _stack // Get reference to the top i-th T item, optionally as a U. I.e. it skips // the i-th T items returning it as U&. template - remove_cref_t & top(int i = 0) const + remove_cref_t & top(int i = 0) { return *reinterpret_cast( nth( i ) ); } // Get a pointer to the last A-th item skipping over any A pre i-th items. template - remove_cref_t< select_last_t > * get() const + remove_cref_t< select_last_t > * get() { using U = remove_cref_t< select_last_t >; return static_cast( advance(data) ); @@ -357,7 +357,7 @@ struct _stack void * start = nullptr; void * end = nullptr; - mutable void * data = nullptr; + void * data = nullptr; using cleanup_f = void(*)( _stack*, int32_t ); struct cleanup_info { @@ -383,7 +383,7 @@ struct _stack } template - remove_cref_t * nth( int32_t n ) const + remove_cref_t * nth( int32_t n ) { using U = remove_cref_t; assert( ((ptrdiff_t)data) > (1<<4) ); @@ -418,9 +418,12 @@ struct _stack template static void * advance(void * p) { - return (char*)p + assert( ((ptrdiff_t)p) > (1<<4) ); + p = static_cast(p) + sum_advance_size::value - advance_size< select_last_t >::value; + assert( ((ptrdiff_t)p) > (1<<4) ); + return p; } template