2
0
mirror of https://github.com/boostorg/pfr.git synced 2026-01-19 04:22:13 +00:00

Fix for 'Arrays of Length Zero' compiler extension (#213)

This commit is contained in:
Antony Polukhin
2025-06-20 15:56:51 +03:00
committed by GitHub
parent 2e3663d0df
commit dcf2deb959
2 changed files with 34 additions and 1 deletions

View File

@@ -0,0 +1,33 @@
// Copyright (c) 2025-2025 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)
// Test that PFR works with GCCs "Arrays of Length Zero" extension
#include <boost/pfr/core.hpp>
#include <tuple>
#if defined(__GNUC__) && (BOOST_PFR_USE_LOOPHOLE || BOOST_PFR_USE_CPP17)
struct zero_array {
char data[0];
};
struct aggr {
zero_array a;
};
static_assert(sizeof(zero_array) == 0);
static_assert(sizeof(aggr) == 0);
int main() {
aggr a;
const auto result = boost::pfr::structure_tie(a);
static_assert(std::tuple_size<decltype(result)>::value == 1);
return sizeof(std::get<0>(result).data);
}
#else
int main() {}
#endif