This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
RE: zero sized structs
- From: "GARCIA DE SORIA LUCENA, JUAN JESUS" <juanj dot g_soria at grupobbva dot com>
- To: "nadult" <nadult at gmail dot com>, <gcc at gcc dot gnu dot org>
- Date: Thu, 13 Nov 2008 11:07:04 +0100
- Subject: RE: zero sized structs
- References: <491B6564.1000902@gmail.com>
> -----Original Message-----
> From: gcc-owner@gcc.gnu.org [mailto:gcc-owner@gcc.gnu.org] On
> Behalf Of nadult
> Sent: Thursday, November 13, 2008 0:23
> To: gcc@gcc.gnu.org
> Subject: zero sized structs
>
> Because of that i can't, for example, create a vector of
> Zero's, i get division by 0 error in max_size().
> Is this a bug, or maybe zero-sized arrays are gcc extension
> not fully supported in g++?
IMHO, conceptually I think this is more of a STL bug than a compiler
one. In the special case that the size of elements is zero, std::vector
should just use the max size_type value for max_size(). All allocations
will be zero-sized, and as actually the maximum allocatable vector would
have infinite elements, the maximum index value is rather restricted by
the maximum number that can be encoded in size_type.
For many cases (specially template programming) I don't want empty
structs without virtual functions to use any space.
Regards,
Juan Jesus.