The C++ Standard (2003) clearly says that instantiating a standard container with an incomplete type invokes undefined-behavior.
The spec says in §17.4.3.6/2,
In particular, the effects are undefined in the following cases:
__ [..]
— if an incomplete type (3.9) is used as a template argument when instantiating a template component.
__ [..]
Things have changed with the C++17 standard, which explicitely allows this types of recursion for std::list
, std::vector
and std::forward_list
. For reference, see http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4510.html and this answer: How can I declare a member vector of the same class?