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

2024-04-18


2250. Implicit instantiation, destruction, and TUs

Section: 13.8.4.1  [temp.point]     Status: open     Submitter: Dawn Perchik     Date: 2016-03-21

Consider:

  template<class T> struct A {
    T* p;
    A();
    ~A() {
	if (0 < sizeof (T))
	  delete p;
    }
  };
  struct U;
  struct C {
    C();
    ~C();
    A<U> u;
  };
  int main() {
    C c;
    return 0;
  }

The intent is that A<U>::~A is instantiated where the special member functions of C are defined (at which point U is ostensibly complete). Preventing instantiation (and thus avoiding the completeness check) in the present translation unit is necessary for the unique_ptr-based pimpl idiom to work.

Notes from the December, 2016 teleconference:

The problem is that the current wording only connects name lookup with point of instantiation; other semantic checks, such as the requirement for completeness of a class, should also be performed at that point.