diff --git a/include/boost/endian/arithmetic.hpp b/include/boost/endian/arithmetic.hpp index f620f7e..062d8ce 100644 --- a/include/boost/endian/arithmetic.hpp +++ b/include/boost/endian/arithmetic.hpp @@ -182,6 +182,13 @@ class endian_arithmetic private: typedef endian_buffer buffer_type; + +#ifdef BOOST_ENDIAN_NO_CTORS +public: +#else +private: +#endif + buffer_type buf_; public: diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index fc54c88..f2a3b67 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -111,3 +111,4 @@ run-ni endian_reverse_test5.cpp ; run packed_buffer_test.cpp ; run arithmetic_buffer_test.cpp ; +run packed_arithmetic_test.cpp ; diff --git a/test/packed_arithmetic_test.cpp b/test/packed_arithmetic_test.cpp new file mode 100644 index 0000000..103429a --- /dev/null +++ b/test/packed_arithmetic_test.cpp @@ -0,0 +1,33 @@ +// Copyright 2020 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt + +#if !defined(__GNUC__) + +#include +BOOST_PRAGMA_MESSAGE( "Skipping test because __GNUC__ is not defined" ) +int main() {} + +#else + +#define BOOST_ENDIAN_FORCE_PODNESS +#define BOOST_ENDIAN_NO_CTORS +#include +#include + +using namespace boost::endian; + +struct X +{ + big_uint16_t a; + double b; + little_uint16_t c; +} __attribute__((packed)); + +int main() +{ + BOOST_TEST_EQ( sizeof( X ), 12 ); + return boost::report_errors(); +} + +#endif