https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105544
--- Comment #8 from ibuclaw at gcc dot gnu.org --- (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;