Created on 2004-01-07.00:00:00 last changed 196 months ago
[Voted into WP at October 2005 meeting.]
Proposed resolution (October, 2004):
At the end of 13.8.3.3 [temp.dep.expr] paragraph 4, add after the list that ends with throw assignment-expression:
[Note: For the standard library macro offsetof, see 17.2 [support.types]. —end note]
At the end of 13.8.3.4 [temp.dep.constexpr] paragraph 2, add after the list that ends with sizeof(type-id):
[Note: For the standard library macro offsetof, see 17.2 [support.types]. —end note]
In 17.2 [support.types] paragraph 4, replace
The macro offsetof accepts a restricted set of type arguments in this International Standard. If type is not a POD structure or a POD union the results are undefined. The result of applying the offsetof macro to a field that is a static data member or a function member is undefined.
with
The macro offsetof(type, member-designator) accepts a restricted set of type arguments in this International Standard. If type is not a POD structure or a POD union ( Clause 11 [class]), the results are undefined. The expression offsetof(type, member-designator) is never type-dependent (13.8.3.3 [temp.dep.expr]) and it is value-dependent (13.8.3.4 [temp.dep.constexpr]) if and only if type is dependent. The result of applying the offsetof macro to a field that is a static data member or a function member is undefined.
[Note: the original wording shown here reflects the resolutions of library issues 306 and 449.]
Notes from the March 2004 meeting:
Note that any such requirement would be in the library section, not core.
As far as I can tell, the standard doesn't say whether "offsetof(...)" is type-dependent. In the abstract, it shouldn't be -- an "offsetof" expression is always of type "size_t". But the standard doesn't say to what the definition of the macro is, so I don't think one can deduce that it will always be considered non-dependent by a conforming compiler.
John Spicer: (1) I agree that you can't know if offsetof is dependent because you don't know what it expands to. (2) In principle, offsetof should be like sizeof -- it is value-dependent if its argument is type-dependent.
Mark Mitchell: I think we should say that: (a) offsetof is not type-dependent, and (b) offsetof is value dependent iff the first argument is type-dependent
Everyone is using slightly different builtins to implement this functionality, and I don't think that there's any guarantee that they're all behaving the same here.
History | |||
---|---|---|---|
Date | User | Action | Args |
2008-10-05 00:00:00 | admin | set | status: wp -> cd1 |
2006-04-22 00:00:00 | admin | set | status: dr -> wp |
2005-10-22 00:00:00 | admin | set | messages: + msg1285 |
2005-10-22 00:00:00 | admin | set | status: ready -> dr |
2005-05-01 00:00:00 | admin | set | status: review -> ready |
2004-11-07 00:00:00 | admin | set | messages: + msg1070 |
2004-11-07 00:00:00 | admin | set | status: open -> review |
2004-04-09 00:00:00 | admin | set | messages: + msg996 |
2004-01-07 00:00:00 | admin | create |