https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90411
Bug ID: 90411 Summary: Colored diagnostics can omit characters Product: gcc Version: 8.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: other Assignee: unassigned at gcc dot gnu.org Reporter: m101010a at gmail dot com Target Milestone: --- gcc prints EL (\33[K) every time it changes the text color to erase the rest of the line. If the cursor is at the end of the line, EL will clear the last character on the line (tested in xterm 344, urxvt 19.22, and even the Windows 10 terminal). This can cause diagnostic information to be incorrect. To reproduce: 1. Set your terminal to 64 columns wide (an easy way to do this is to run "printf '\e[8;25;64t'") 2. Run "printf 'void g(int); void f(){g((int*)0);}' | env LC_ALL=C gcc -x c - -fdiagnostics-color=always -fsyntax-only" Note the line that says "<stdin>:1:8: note: expected 'int' but argument is of type 'int '" 3. Resize the terminal to 66 columns or wider 4. Run "printf 'void g(int); void f(){g((int*)0);}' | env LC_ALL=C gcc -x c - -fdiagnostics-color=always -fsyntax-only" again Note that the line is now "<stdin>:1:8: note: expected 'int' but argument is of type 'int *'" This can be fixed by only printing ELs at the end of lines and ending all colored lines with a space, but that will cause tabs to have the wrong color (see the comment at the top of gcc/color-macros.h) and will cause lines that would be exactly the terminal width to be followed by a blank line.