Title
N3986 Adding Standard support to avoid padding within structures
Status
open
Section
[class.bit]
Submitter
S. Davalle, D. Gutson, A. Bustamante

Created on 2014-05-06.00:00:00 last changed 128 months ago

Messages

Date: 2014-07-01.21:57:43

http://open-std.org/JTC1/SC22/WG21/docs/papers/2014/n3986.pdf

The paper contains the proposed wording.

Discussed in Rapperswil 2014. Not polled yet.

Garcia thought attributes should be explored as a solution rather than using a bitfield of negative width. Stroustrup asked why the facility is per-field rather than per-class. Gutson explained that he doesn't always want pack whole structures, and Stroustrup and Tomazos pointed out that splitting a larger class into smaller ones should solve the problem.

Vandevoorde pointed out implementation issues and asked what happens if a target architecture doesn't support the resulting padding (or the lack of it). It was suggested that the current standard may allow implementations to diagnose such cases anyway.

Naumann made the point that he thinks code should be portable but that object layout cannot be specified in such a strict manner due to architecture differences. Smolsky asked whether there are plans to impose endianness requirements on the representation of built-in types, and voiced concern about a performance impact.

Wong expressed doubt whether a standard solution is necessary, since every vendor has a solution. Vandevoorde replied that that sounds like a good reason to provide a standard solution.

Bos asked why there needs to be this support in classes rather than manipulating bits with a function. Dennett pointed out that this proposal turns things that aren't bitfields into bitfield-like things, because what looks like an int cannot be treated as an int.

Vandevoorde pointed out that alignas is almost a solution, but it doesn't apply to bitfields, and suggested using arrays instead of plain ints for the data that needs to be packed. Stroustrup recommended doing a survey of existing practice.

History
Date User Action Args
2014-05-06 00:00:00admincreate