This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: funny problem with g++


Morten Welinder wrote:
>>>This is a joke, you are kidding, right ?
>>
>>No, we're not kidding.  RTFM: Section, 5.12 Arrays of Length Zero
> 
> 
> He is kind of right, though.  Outside struct (or perhaps union),
> zero-sized arrays
> make little sense and could be rejected.  Or else I am missing something too.

If you've got an array that is a cache of items and you have a constant
defined that specifies how many cache entries to use, then you can tune
the cache size to any number except zero. That doesn't make any sense,
but being able to define a zero length array *does* make sense. The
alternative is to hide the array in an extra layer of templates, and to
specialise it for zero to not use a real array in its implementation,
and that's so nasty.

IMHO, this is a good extension, at least until boost::array gets
standardised.

-- 
Tristan Wibberley


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]