This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 115e. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.
2024-11-11
[Adopted at the June, 2018 meeting as part of papeer P0929R2.]
According to 9.3.4.5 [dcl.array] paragraph 1, an array declarator whose element type is an abstract class is ill-formed. However, if the element type is a class template specialization, it may not be known that the class is abstract; because forming an array of an incomplete type is permitted (6.8 [basic.types] paragraphs 5-6), the class template is not required to be instantiated in order to use it as an element type. The expected handling if the class template is later instantiated is unclear; should the compiler issue an error about the earlier array array type at the point at which the class template is instantiated?
This also affects overload resolution:
template<typename> struct Abstract { virtual void f() = 0; typedef int type; }; template<typename T> char &abstract_test(T[1]); // #1 template<typename T> char (&abstract_test(...))[2]; // #2 // Abstract<int>::type n; static_assert(sizeof(abstract_test<Abstract<int>>(nullptr)) == 2, "");
Overload resolution will select #1 and fail the assertion; if the commented line is uncommented, there is implementation variance, but presumably #2 should be selected and satisfy the assertion.
These effects of completing the type are troublesome. Would it be better to allow array types of abstract element type and simply prohibit creation of objects of such arrays?
(See also issue 1646.)