Defect Report #282

Previous Defect Report < - > First Defect Report
 

Submitter: Douglas Walls (US)
Submission Date: 2002-06-11
Source: J11
Version: 1.1
Date: 2003-03-06
Subject: flexible array members & struct padding
Summary
 

6.7.2.1 Structure and union specifiers, paragraphs 15 and 16 require that any padding for
alignment of a structure containing a flexible array member must preceed the flexible
array member.  This contradicts existing implementations.  We do not believe this was the intent of the C99 specification.

Details

If a struct contains a flexible array member and also requires padding for alignment, then the current C99 specification requires the implementation to put this padding before the flexible array member.  However, existing implementations, including at least GNU C, Compaq C, and Sun C, put the padding after the flexible array member.

The layout used by existing implementations can be more efficient. Furthermore, requiring these existing implementations to change their layout would break binary backwards compatibility with previous versions.

Suggested Technical Corrigendum

Change the wording such that it is implementation defined as to whether the padding is before or after the flexible array member.  


Proposed Technical Corrigendum

In 6.7.2.1 paragraph 16.

After footnote 106, replace period with comma and add "plus the number of bytes of unnamed padding (if any)."

Change example in paragraph 17 to reflect this change.

Change example in paragraph 20 to reflect this change.

In 6.2.6.1 paragraph 6 Representation of types. 1st sentence.

Add, ", or any flexible array member," after "any padding bytes".

Previous Defect Report < - > First Defect Report