From cbc57cc28758c36c77b3fbe4e4ef7fb8e98f5ae8 Mon Sep 17 00:00:00 2001 From: Zachary Wassall Date: Fri, 20 Sep 2024 18:53:04 -0400 Subject: [PATCH] Test field count for huge types --- test/core/run/huge_count.cpp | 57 ++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 test/core/run/huge_count.cpp diff --git a/test/core/run/huge_count.cpp b/test/core/run/huge_count.cpp new file mode 100644 index 00000000..cdb30105 --- /dev/null +++ b/test/core/run/huge_count.cpp @@ -0,0 +1,57 @@ +// Copyright (c) 2024 Antony Polukhin +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#include + +#include +#include + +#if defined(__clang__) +#define ARRAY_MAX (SIZE_MAX >> 3) +#define OBJECT_MAX SIZE_MAX +#elif defined(__GNUC__) +#define ARRAY_MAX INT_MAX +#define OBJECT_MAX SIZE_MAX +#else // defined(_MSC_VER) +#define ARRAY_MAX INT_MAX +#define OBJECT_MAX INT_MAX +#endif + +struct A +{ + char x[ARRAY_MAX <= (OBJECT_MAX >> 3) ? ARRAY_MAX : OBJECT_MAX >> 3]; +}; + +struct B +{ + A a; + A b; + A c; + A d; + A e; + A f; + A g; + A h; +}; + +struct C +{ + A& a; + A b; + A c; + A d; + A e; + A f; + A g; + A h; +}; + +int main() { +#ifndef _MSC_VER + static_assert(boost::pfr::tuple_size_v == ARRAY_MAX, ""); +#endif + static_assert(boost::pfr::tuple_size_v == 8, ""); + static_assert(boost::pfr::tuple_size_v == 8, ""); +}