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

Created on 2025-03-20.00:00:00 last changed 2 months ago

Messages

Date: 2025-03-20.00:00:00

(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.

Possible resolution:

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]
History
Date User Action Args
2025-03-20 00:00:00admincreate