Subject: [Boost-bugs] [Boost C++ Libraries] #13614: padding related issue on VS2017 with boost::endian
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2018-06-21 04:51:38
#13614: padding related issue on VS2017 with boost::endian
------------------------------+-------------------------
Reporter: imak@⦠| Owner: Beman Dawes
Type: Bugs | Status: new
Milestone: To Be Determined | Component: endian
Version: Boost 1.67.0 | Severity: Problem
Keywords: |
------------------------------+-------------------------
On Visual Studio 2017 upd3, there seems to be some unexpected padding-
related behaviour, shown below. The issue might not necessarily be a
library 'bug', but I think it's worth looking at.
{{{
#!div style="font-size: 80%"
Code highlighting:
{{{#!c++
#include <stdio.h>
#include <boost/endian/arithmetic.hpp>
using namespace boost::endian;
#pragma pack(push, 1)
struct Empty {};
struct T1
{
big_uint16_t d;
uint8_t d2;
};
struct T2
{
uint16_t d;
uint8_t d2;
};
struct D0: T1 {} x0; // sizeof(x0) evaluates to 3
struct D1: T1, Empty {} x1; // sizeof(x1) evaluates to 4 <- i think
this should also be 3
struct D2: T2, Empty {} x2; // sizeof(x2) evaluates to 3
// (uint8_t*)&x1.d2 - (uint8_t*)&x1.d evaluates to 2 (i.e. big_uint16_t
is itself not padded)
//
// - tested with a struct containing a char[2], this did not happen
// - tested on various versions of g++ and clang, but this did not happen
either.
#pragma pack(pop)
using namespace std;
int main()
{
printf("%zu %zu %zu", sizeof(x0), sizeof(x1), sizeof(x2));
return 0;
}
}}}
}}}
-- Ticket URL: <https://svn.boost.org/trac10/ticket/13614> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2018-06-21 04:58:29 UTC