https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105544

--- Comment #6 from Fabian Vogt <fab...@ritter-vogt.de> ---
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...

With explicit termination it works:

~> echo -e "pragma(msg, int(__VERSION__));\0" | /usr/bin/gdc -x d -
2076
/usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld:
/usr/lib64/gcc/x86_64-suse-linux/11/../../../../lib64/Scrt1.o: in function
`_start':
/home/abuild/rpmbuild/BUILD/glibc-2.35/csu/../sysdeps/x86_64/start.S:103:
undefined reference to `main'
collect2: error: ld returned 1 exit status

This also explains the huge amount of diagnostic messages, which are random
based on the content past the module source buffer. It just runs until it
encounters a terminator by accident.

strace -k shows that the attempts to open "<stdin>" are actually caused by the
printing of diagnostic messages itself, arguably a separate bug.

Reply via email to