This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 110. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2022-11-27


328. Missing requirement that class member types be complete

Section: 11.4  [class.mem]     Status: CD1     Submitter: Michiel Salters     Date: 10 Dec 2001

[Voted into WP at March 2004 meeting.]

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. <3c07c8fb$0$8507$ed9e5944@reading.news.pipex.net>

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.