Avoid char[] array in tree_def
Richard Biener
rguenther@suse.de
Thu Oct 29 16:04:27 GMT 2020
On Thu, 29 Oct 2020, Jan Hubicka wrote:
> >
> > That's ugly and will for sure defeat warning / access code
> > when we access this as char[], no? I mean, we could
> > as well use 'int str[1];' here?
>
> Well, we always get char pointer via macro that is IMO OK, but I am also
> not very much in love with this.
> >
> > Maybe we can invent some C++ attribute for this?
> >
> > [[gnu::string]]
> >
> > or so that marks it as actual char and not typeless storage?
>
> Attribute would probably make sense. Not sure if gnu::string is best
> name given that it can be also meaningful for array of small integers
> (such as in wide_int).
OK, maybe [[gnu::strictly_typed]] then?
> Honza
> >
> > Richard.
> >
> > > };
> > >
> > > struct GTY(()) tree_complex {
> > > diff --git a/gcc/tree.c b/gcc/tree.c
> > > index 81f867ddded..84115630184 100644
> > > --- a/gcc/tree.c
> > > +++ b/gcc/tree.c
> > > @@ -2273,7 +2273,7 @@ build_string (unsigned len, const char *str /*= NULL */)
> > > memcpy (s->string.str, str, len);
> > > else
> > > memset (s->string.str, 0, len);
> > > - s->string.str[len] = '\0';
> > > + s->string.str[len].c = '\0';
> > >
> > > return s;
> > > }
> > >
> >
> > --
> > Richard Biener <rguenther@suse.de>
> > SUSE Software Solutions Germany GmbH, Maxfeldstrasse 5, 90409 Nuernberg,
> > Germany; GF: Felix Imend
>
--
Richard Biener <rguenther@suse.de>
SUSE Software Solutions Germany GmbH, Maxfeldstrasse 5, 90409 Nuernberg,
Germany; GF: Felix Imend
More information about the Gcc-patches
mailing list