public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "fabian@ritter-vogt.de" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug d/105544] gdc fails to compile d source from stdin
Date: Thu, 12 May 2022 09:44:56 +0000 [thread overview]
Message-ID: <bug-105544-4-ZkhPScS8Uo@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-105544-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105544
--- Comment #9 from Fabian Vogt <fabian@ritter-vogt.de> ---
(In reply to ibuclaw from comment #8)
> (In reply to Fabian Vogt from comment #6)
> > I had a quick debugging session: The DMD lexer code doesn't really care
> > about the size of the buffer and instead runs until it encounters either a 0
> > or 0x1A byte. The stdin read loop in d_parse_file doesn't explicitly
> > 0-terminate the buffer, which means that it works randomly...
> >
>
> OK, so the suggestion would be to zero the padding at the end of the input
> buffer then.
>
> --- a/gcc/d/d-lang.cc
> +++ b/gcc/d/d-lang.cc
> @@ -1072,6 +1072,10 @@ d_parse_file (void)
> global.params.doHdrGeneration);
> modules.push (m);
>
> + /* Zero the padding past the end of the buffer so the D lexer has a
> + sentinel. The lexer only reads up to 4 bytes at a time. */
> + memset (buffer + len, '\0', 16);
> +
> /* Overwrite the source file for the module, the one created by
> Module::create would have a forced a `.d' suffix. */
> m->src.length = len;
Yep, that should work. Though I wonder why 16B of padding and not just a single
byte for the 0. FWICT the lexer reads a single byte at a time only (utf8_t is
an unsigned char), so it should stop at the first 0.
The comment above explaining the padding mentions a "final '\n'" which should
probably be adjusted with the change to \0.
next prev parent reply other threads:[~2022-05-12 9:44 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-10 9:33 [Bug d/105544] New: " fabian@ritter-vogt.de
2022-05-10 9:34 ` [Bug d/105544] " fabian@ritter-vogt.de
2022-05-10 9:35 ` marxin at gcc dot gnu.org
2022-05-10 12:11 ` ibuclaw at gcc dot gnu.org
2022-05-10 12:14 ` marxin at gcc dot gnu.org
2022-05-11 22:06 ` ibuclaw at gcc dot gnu.org
2022-05-12 6:58 ` marxin at gcc dot gnu.org
2022-05-12 7:39 ` fabian@ritter-vogt.de
2022-05-12 7:47 ` marxin at gcc dot gnu.org
2022-05-12 9:32 ` ibuclaw at gcc dot gnu.org
2022-05-12 9:44 ` fabian@ritter-vogt.de [this message]
2022-05-12 12:58 ` ibuclaw at gcc dot gnu.org
2022-05-12 13:18 ` fabian@ritter-vogt.de
2022-05-31 16:32 ` cvs-commit at gcc dot gnu.org
2022-05-31 16:33 ` cvs-commit at gcc dot gnu.org
2022-05-31 16:37 ` ibuclaw at gdcproject dot org
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=bug-105544-4-ZkhPScS8Uo@http.gcc.gnu.org/bugzilla/ \
--to=gcc-bugzilla@gcc.gnu.org \
--cc=gcc-bugs@gcc.gnu.org \
/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).