-
Notifications
You must be signed in to change notification settings - Fork 8
Closed
Description
Full name of submitter (unless configured in github; will be published with the issue): Jiang An
Reference (section label): [basic.types.general]
Link to reflector thread (if any):
Issue description:
Currently two types are layout-compatible only in a few cases (ignoring top-level cv-qualifiers at first):
- they are the same type, or
- they are layout-compatible classes, or
- they are layout-compatible enumeration types, i.e. enumeration types with the same underlying type.
There are possibly some other cases in which two types share the same size, alignment, and representation, but not layout-compatible:
- an enumeration type and its underlying type (also mentioned in CWG2590 [dcl.enum] Underlying type of enum should determine its size and alignment requirement #39 ),
- two array types of the same length and layout-compatible but different element types,
- e.g.
Foo[1]andBar[1], whereFooandBarare layout-compatible classes,
- e.g.
- two "similar" but different types, but perhaps the pre-C++20 (pre-P0388) similarity should used because similarity is no longer an equivalence relation (losing transitivity) since C++20,
- e.g.
char*andchar const*,
- e.g.
- two types
T1andT2, whoseUtypes in qualification decomposition (denoted byU1andU2here) are layout-compatible, and they would become similar ifU1andU2were replaced with the same type,- e.g.
Foo*andBar const*,
- e.g.
- signed and unsigned integer type counterparts,
boolor an encoded character type and its underlying type,- two other arithmetic types with the same size, alignment, and representation,
- e.g.
intandlongin ILP32, ordoubleandlong doublein MSVC ABI.
- e.g.
This is not strictly a defect, but it's not clear to me whether the current specification is reflecting the intent of design. It might be better to extend layout-compatibility to include some or all of these cases, while keeping being an equivalence relation.
Metadata
Metadata
Assignees
Labels
No labels