> -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 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.