From fba0d527fd05d5e9cf4e15ae390eb7518326c7c1 Mon Sep 17 00:00:00 2001 From: Thierry Treyer Date: Wed, 10 Jan 2024 07:07:47 -0800 Subject: [PATCH] Fix static_assert failure for zero-length array The recursive template implemented for `validate_size` does not support incomplete types, like zero-length array. By splitting the `validate_size` struct in two parts: 1. `validate_size_eq` that does the actual size check, and 2. `validate_size` that preserves the previous interface and inherit from `validate_size_eq`, we get the same interface and feature than previously, but without the recursive template that doesn't support incomplete types. --- oi/OITraceCode.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/oi/OITraceCode.cpp b/oi/OITraceCode.cpp index a100900..323c83e 100644 --- a/oi/OITraceCode.cpp +++ b/oi/OITraceCode.cpp @@ -160,15 +160,14 @@ template struct DummyAllocator : DummyAllocatorBase {}; -template -struct validate_size { +template +struct validate_size_eq { static constexpr bool value = true; static_assert(ExpectedSize == ActualSize); }; template -struct validate_size - : validate_size {}; +struct validate_size : validate_size_eq {}; template struct validate_offset {