This is the mail archive of the gcc-bugs@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]

Re: Wrong optimization in current CVS


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.

20001115-1.c

20001115-1.c.diff


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