Title
Confusing note about ordinary character types for aligned memory areas
Status
drafting
Section
6.7.3 [basic.align]
Submitter
Xavier Bonaventura

Created on 2025-03-20.00:00:00 last changed 1 week ago

Messages

Date: 2025-06-15.00:00:00

Additional notes (June, 2025)

The "underlying type" is for enumerations and derived integer types and thus is the wrong phrase to use here.

Date: 2025-06-12.22:26:13

Proposed resolution (no objections during CWG reflector review starting 2025-05-11):

Change in 6.7.3 [basic.align] paragraph 6 as follows:

The alignment requirement of a complete type can be queried using an alignof expression (7.6.2.6 [expr.alignof]). Furthermore, the narrow character types (6.8.2 [basic.fundamental]) shall have the weakest alignment requirement. [Note 2: This enables the ordinary character types to The type unsigned char can be used as the underlying type for an aligned memory area (9.13.2 [dcl.align]). —end note]
Date: 2025-06-12.22:26:13

(From submission #687.)

Subclause 6.7.3 [basic.align] paragraph 6 specifies:

The alignment requirement of a complete type can be queried using an alignof expression (7.6.2.6 [expr.alignof]). Furthermore, the narrow character types (6.8.2 [basic.fundamental]) shall have the weakest alignment requirement. [Note 2: This enables the ordinary character types to be used as the underlying type for an aligned memory area (9.13.2 [dcl.align]). —end note]

The note has multiple problems: First, the note talks about "ordinary character types" (including char8_t; see 6.8.2 [basic.fundamental] paragraph 7), whereas the immediately preceding sentence is limited to "narrow character types". Second, due to memory model concerns, signed char is not suitable for aligned memory areas providing storage for other objects.

History
Date User Action Args
2025-06-20 12:07:56adminsetmessages: + msg8041
2025-06-20 12:07:56adminsetstatus: tentatively ready -> drafting
2025-06-12 22:26:13adminsetmessages: + msg8035
2025-06-12 22:26:13adminsetstatus: open -> tentatively ready
2025-03-20 00:00:00admincreate