From: Richard Biener <rguenther@suse.de>
To: Bernd Edlinger <bernd.edlinger@hotmail.de>
Cc: Jeff Law <law@redhat.com>,
"gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] Check the STRING_CSTs in varasm.c
Date: Fri, 17 Aug 2018 12:19:00 -0000 [thread overview]
Message-ID: <alpine.LSU.2.20.1808171415270.16707@zhemvz.fhfr.qr> (raw)
In-Reply-To: <AM5PR0701MB2657496F56A49202C9930B90E43D0@AM5PR0701MB2657.eurprd07.prod.outlook.com>
On Fri, 17 Aug 2018, Bernd Edlinger wrote:
> Richard Biener wrote:
> > +embedded @code{NUL} characters. However, the
> > +@code{TREE_STRING_LENGTH} always includes a trailing @code{NUL} that
> > +is not part of the language string literal but appended by the front end.
> > +If the string shall not be @code{NUL}-terminated the @code{TREE_TYPE}
> > +is one character shorter than @code{TREE_STRING_LENGTH}.
> > +Excess caracters other than one trailing @code{NUL} character are not
characters btw.
I read the above that the string literal for
char x[2] = "1";
is actually "1\0\0" - there's one NUL that is not part of the language
string literal. The second sentence then suggests that both \0
are removed because 2 is less than 3?
As said, having this extra semantics of a STRING_CST tied to
another tree node (its TREE_TYPE) looks ugly.
> > +permitted.
> >
> > I find this very confusing and oppose to that change. Can we get
> > back to the drawing board please? If we want an easy way to
> > see whether a string is "properly" terminated then maybe we can
> > simply use a flag that gets set by build_string?
> >
>
> What I mean with that is the case like
> char x[2] = "123456";
>
> which is build_string(7, "123456"), but with a type char[2],
> so varasm throws away "3456\0".
I think varasm throws away chars not because of the type of
the STRING_CST but because of the available storage in x.
> I want to say that this is not okay, the excess precision
> should only be used to strip the nul termination, in cases
> where it is intended to be a assembled as a not zero terminated
> string. But maybe the wording could be improved?
ISTR we always assemble a NUL in .strings to get string merging
working.
Richard.
next prev parent reply other threads:[~2018-08-17 12:19 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-01 11:35 Bernd Edlinger
2018-08-03 21:36 ` Jeff Law
2018-08-03 21:42 ` Bernd Edlinger
2018-08-04 5:55 ` Bernd Edlinger
2018-08-05 10:28 ` Bernd Edlinger
2018-08-17 4:46 ` Jeff Law
2018-08-17 12:13 ` Bernd Edlinger
2018-08-18 3:43 ` Jeff Law
2018-08-17 9:38 ` Richard Biener
2018-08-17 10:38 ` Bernd Edlinger
2018-08-17 12:19 ` Richard Biener [this message]
2018-08-17 12:36 ` Bernd Edlinger
2018-08-17 13:38 ` Richard Biener
2018-08-17 13:53 ` Bernd Edlinger
2018-08-18 3:47 ` Jeff Law
2018-08-22 14:27 ` Bernd Edlinger
2018-08-22 20:54 ` Martin Sebor
2018-08-22 22:52 ` Bernd Edlinger
2018-08-24 20:18 ` Bernd Edlinger
2018-09-13 18:44 ` Jeff Law
2018-09-13 19:08 ` Bernd Edlinger
2018-09-13 18:59 ` Jeff Law
2018-09-13 19:51 ` Bernd Edlinger
2018-09-13 21:32 ` Jeff Law
2018-09-13 22:02 ` Jeff Law
2018-08-17 9:33 ` Richard Biener
2018-08-17 10:22 ` Bernd Edlinger
2018-08-17 12:14 ` Richard Biener
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.LSU.2.20.1808171415270.16707@zhemvz.fhfr.qr \
--to=rguenther@suse.de \
--cc=bernd.edlinger@hotmail.de \
--cc=gcc-patches@gcc.gnu.org \
--cc=law@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).