This is the mail archive of the gcc-patches@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: [PATCH] __builtin_object_size improvements


On Fri, 5 Jun 2009, Richard Henderson wrote:

> Jakub Jelinek wrote:
> > The patch below implements both of these, with the exception that if
> > the field is at the end of the structure and base is INDIRECT_REF,
> > __bos (x, 1) behaves like __bos (x, 0), because there is tons of code out
> > there that uses arrays at the end of a structure instead of flexible array
> > members and I wouldn't like to break code like:
> > struct A { int i; char c[1]; };
> > struct A *p = malloc (sizeof (*p) + strlen ("abcde"));
> > strcpy (p->c, "abcde");
> 
> I'd prefer that this exception only be made if that last array length is
> exactly 1, not any trailing array.

There are many other variants around - we hit this with the array
bound warnings.  So I think we have to treat all trailing arrays
the same.

Richard.


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