http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51731

--- Comment #2 from M.L. Hekkelman <m.hekkelman at cmbi dot ru.nl> 2012-01-02 
17:03:46 UTC ---
Beste paolo.carlini,

maandag 2 januari 2012, 17:23:42, schreef je:

> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51731

> --- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> 
> 2012-01-02 16:23:42 UTC ---
> Maybe I'm just tired (sorry in case) but I really don't see how this can
> possibly work: *negative* index?!? Can you explain?

It  is  a  technique  that  dates back to, who knows when. It is even 
common practice to have a zero sized array in the struct, like this:

struct page
{
       char        keys[1024];
       int         offsets[0];
};

This  way you have a fixed size page you can write to disk containing 
non  terminated strings in keys and the direct offsets to the keys in 
the   offsets  arrays. Fill the page until the keys and offsets would 
collide with the addition of a new key.

E.g. the B-Tree implementation of the HFS file system in MacOS
Classic uses this.

I  have  used  code like this for many years now, and this code works 
with all compilers I'm aware off but not with gcc 4.5 and 4.6.

Reply via email to