Wrong optimization in current CVS

Franz Sirl Franz.Sirl-kernel@lauterbach.com
Fri Nov 17 04:18:00 GMT 2000


At 10:42 17.11.00, Richard Henderson wrote:
>On Thu, Nov 16, 2000 at 01:07:58AM +0100, Franz Sirl wrote:
> > > OK to commit as execute/20001115-1.c?
>
>Not ok.
>
> > struct iso_directory_record {
> >            unsigned char name_len [1];
> >            char name [0];
> > } entry;
>
>entry.name has no storage, therefore ...
>
> >    if (de->name_len[0] == 1 && de->name[0] == 0)
>
>... dereferencing it is incorrect.
>
>You should be able to design a different test case that
>shows this off without being in error.

Ah, I see what you mean. How about:

extern void abort (void);
extern void exit (int);

union iso_directory_record {
    char carr[4];
    struct {
            unsigned char name_len [1];
            char name [0];
    } u;
} entry;

void set(union iso_directory_record *);

int main (void)
{
    union iso_directory_record *de;

    de = &entry;
    set(de);

    if (de->u.name_len[0] == 1 && de->u.name[0] == 0)
      exit (0);
    else
      abort ();
}

void set (union iso_directory_record *p)
{
    p->carr[0] = 1;
    p->carr[1] = 0;
    return;
}

Feel free to commit the diff, I won't be able to do so until Sunday evening

Franz.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 20001115-1.c
Type: text/x-c
Size: 504 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-bugs/attachments/20001117/f18907b5/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 20001115-1.c.diff
Type: text/x-diff
Size: 906 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-bugs/attachments/20001117/f18907b5/attachment-0001.bin>


More information about the Gcc-bugs mailing list