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:
33
test/core/run/zero_size_array.cpp
Normal file
33
test/core/run/zero_size_array.cpp
Normal 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
|
||||
|
||||
Reference in New Issue
Block a user