https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121690
--- Comment #11 from Andrew Pinski <pinskia at gcc dot gnu.org> --- So here is what I think happens. the \n happens at the end of the buffer so it is changed into \n\r into the buffer and then the next character from the tty is \r. This sounds like an expect or a dejagnu bug handling of \n at the end of the buffer rather than peeking to see if the next character was \r too.