From 1a8b098ed048e0b1e3e336db3684dce4df0f9d73 Mon Sep 17 00:00:00 2001 From: Ferdinand Bachmann Date: Mon, 12 May 2025 15:20:33 +0200 Subject: [PATCH] ring-buffer-iterator: fix postfix increment/decrement this silently did the wrong thing on g++ (precedence of postfix ++/--) and didn't compile on clang++. The correct solution is to prefix-increment, which has no precedence issues and calls the correct function. Postfix-increment with correct precedence would have resulted in a stack overflow anyway. --- include/ring-buffer-iterator.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/ring-buffer-iterator.h b/include/ring-buffer-iterator.h index f11fc0f..b599060 100644 --- a/include/ring-buffer-iterator.h +++ b/include/ring-buffer-iterator.h @@ -61,7 +61,7 @@ public: } CONSTEXPR ring_buffer_iterator operator++(int) NOEXCEPT { ring_buffer_iterator old = *this; - *this++; + ++*this; return old; } CONSTEXPR ring_buffer_iterator& operator--() NOEXCEPT { @@ -70,7 +70,7 @@ public: } CONSTEXPR ring_buffer_iterator operator--(int) NOEXCEPT { ring_buffer_iterator old = *this; - *this--; + --*this; return old; } @@ -161,7 +161,7 @@ public: } CONSTEXPR ring_buffer_const_iterator operator++(int) NOEXCEPT { ring_buffer_const_iterator old = *this; - *this++; + ++*this; return old; } CONSTEXPR ring_buffer_const_iterator& operator--() NOEXCEPT { @@ -170,7 +170,7 @@ public: } CONSTEXPR ring_buffer_const_iterator operator--(int) NOEXCEPT { ring_buffer_const_iterator old = *this; - *this--; + --*this; return old; }