This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of CD1 status.

306. offsetof macro and non-POD types

Section: 17.2 [support.types] Status: CD1 Submitter: Steve Clamage Opened: 2001-02-21 Last modified: 2016-01-28

Priority: Not Prioritized

View all other issues in [support.types].

View all issues with CD1 status.

Discussion:

Spliced together from reflector messages c++std-lib-8294 and -8295:

18.1, paragraph 5, reads: "The macro offsetof accepts a restricted set of type arguments in this International Standard. type shall be a POD structure or a POD union (clause 9). The result of applying the offsetof macro to a field that is a static data member or a function member is undefined."

For the POD requirement, it doesn't say "no diagnostic required" or "undefined behavior". I read 4.1 [intro.compliance], paragraph 1, to mean that a diagnostic is required. It's not clear whether this requirement was intended. While it's possible to provide such a diagnostic, the extra complication doesn't seem to add any value.

Proposed resolution:

Change 18.1, paragraph 5, to "If type is not a POD structure or a POD union the results are undefined."

[Copenhagen: straw poll was 7-4 in favor. It was generally agreed that requiring a diagnostic was inadvertent, but some LWG members thought that diagnostics should be required whenever possible.]