Title
offsetof is unnecessarily imprecise
Status
c++17
Section
[support.types]
Submitter
Richard Smith

Created on 2016-05-10.00:00:00 last changed 81 months ago

Messages

Date: 2016-06-27.16:42:33

Proposed resolution:

This wording is relative to N4582.

  1. Change in [support.types]/4:

    -4- The macro offsetof(type, member-designator) accepts a restricted set of type arguments in this International Standard. If type is notUse of the offsetof macro with a type other than a standard-layout class (Clause 9), the results are undefinedis conditionally-supported.193 The expression offsetof(type, member-designator) is never type-dependent (14.6.2.2) and it is value-dependent (14.6.2.3) if and only if type is dependent. The result of applying the offsetof macro to a static data member or a function member is undefined. No operation invoked by the offsetof macro shall throw an exception and noexcept(offsetof(type, member-designator)) shall be true.

Date: 2016-06-27.16:42:33

[ 2016-06 Oulu ]

The concern about errors appears to be less severe that we thought. Moving to Ready.

Friday: status to Immediate

Date: 2017-02-02.00:41:18

[ 2016-05 Issues Telecon ]

People were worried about the requirement to report errors implied by 'conditionally supported'.

Date: 2016-05-10.00:00:00

Per [support.types]/4:

"The macro offsetof(type, member-designator) accepts a restricted set of type arguments in this International Standard. If type is not a standard-layout class (Clause 9), the results are undefined. [...]"

Implementations in practice interpret this as meaning that the program is ill-formed for classes that are not standard-layout, but several implementations allow additional types as an extension (rejected in their "strictly conforming" modes).

It would seem superior to specify that implementation-defined extensions are permitted, and that the implementation must give a correct answer for any type that it chooses to accept.

History
Date User Action Args
2017-07-30 20:15:43adminsetstatus: wp -> c++17
2016-06-28 13:14:43adminsetstatus: immediate -> wp
2016-06-27 16:42:33adminsetmessages: + msg8203
2016-06-27 16:42:33adminsetstatus: new -> immediate
2016-05-22 15:38:38adminsetmessages: + msg8144
2016-05-11 20:33:47adminsetmessages: + msg8121
2016-05-10 00:00:00admincreate