Created on 2001-12-10.00:00:00 last changed 162 months ago
[Voted into WP at March 2004 meeting.]
Proposed Resolution (April 2002, revised April 2003):
Change the first bullet of the note in 6.3 [basic.def.odr] paragraph 4 and add two new bullets following it, as follows:
Replace 11.4 [class.mem] paragraph 8 by:
Non-static (11.4.9 [class.static]) data members shall not have incomplete types. In particular, a class C shall not contain a non-static member of class C, but it can contain a pointer or reference to an object of class C.
See also 6.8 [basic.types] paragraph 6, which is relevant but not changed by the Proposed Resolution.
Is it legal to use an incomplete type (6.8 [basic.types] paragraph 6) as a class member, if no object of such class is ever created ?
And as a class template member, even if the template is instantiated, but no object of the instantiated class is created?
The consensus seems to be NO, but no wording was found in the standard which explicitly disallows it.
The problem seems to be that most of the restrictions on incomplete types are on their use in objects, but class members are not objects.
A possible resolution, if this is considered a defect, is to add to 6.3 [basic.def.odr] paragraph 4, (situations when T must be complete), the use of T as a member of a class or instantiated class template.
The thread on comp.std.c++ which brought up the issue was "Compiler differences: which is correct?", started 2001 11 30. <email@example.com>
|2008-10-05 00:00:00||admin||set||status: wp -> cd1|
|2004-04-09 00:00:00||admin||set||messages: + msg1014|
|2004-04-09 00:00:00||admin||set||status: ready -> wp|
|2003-11-15 00:00:00||admin||set||status: review -> ready|
|2003-04-25 00:00:00||admin||set||status: ready -> review|
|2002-11-08 00:00:00||admin||set||status: review -> ready|
|2002-05-10 00:00:00||admin||set||messages: + msg622|
|2002-05-10 00:00:00||admin||set||status: open -> review|