This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/53248] std::array<T,0> doesn't work when T is not default-constructible
- From: "daniel.kruegler at googlemail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 05 May 2012 21:16:36 +0000
- Subject: [Bug libstdc++/53248] std::array<T,0> doesn't work when T is not default-constructible
- Auto-submitted: auto-generated
- References: <bug-53248-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53248
Daniel KrÃgler <daniel.kruegler at googlemail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |daniel.kruegler at
| |googlemail dot com
--- Comment #1 from Daniel KrÃgler <daniel.kruegler at googlemail dot com> 2012-05-05 21:16:36 UTC ---
(In reply to comment #0)
> Looking at <array> on the web at your documentation pages, there is no
> specialization of "std::array<T,N>" for "std::array<T,0>"; you just nudge the
> element count to 1 when it would have been zero. That secret element still
> needs to be specified, since std::type_index doesn't have a default
> constructor, although no initializers are logically necessary for an empty
> array (i.e. the work-around abstraction leaks).
>
> The first way I see around it is to make an explicit specialization that's
> data-less.
While I completely agree with your suggestion but I need to say that
unfortunately this is not what the library specification requires. The current
wording in fact allows implementations of the form found here. There is (again:
unfortunately) nothing that requires that std::array<T, 0> shall be
default-constructible irrespective of whether T is default-constructible, for
example.
I cannot speak for the decisions made in libstdc++ in regard to std::array's
optimized zero-size support, but I would like to encourage you to submit a
library issue to the email-address in the beginning of
http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html
for this matter. I really think that it should be required that std::array<T,
0> is always default-constructible.