https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106098
Bug ID: 106098
Summary: error message that uses ANSI codes that can cause
characters to disappear
Product: gcc
Version: 12.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: jonathan.poelen at gmail dot com
Target Milestone: ---
Created attachment 53204
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53204&action=edit
comparison between a 106 and 127 column terminal
int main() {
char const* b = "" + "";
}
$ g++ -fdiagnostics-color=always test.cpp
test.cpp: In function ‘int main()’:
test.cpp:2:22: error: invalid operands of types ‘const char [1]’ and ‘const
char [1]’ to binary ‘operator ’
[...]
On a terminal of 106 characters per line, the `+` sign disappeared. This is due
to the use of the ANSI code \x1b[K which normally removes the characters to the
right of the cursor. However, many terminals make the last character of the
line disappear when this code is used at the end of the line. This is the case
here with a 106 column terminal ($COLUMNS=106).
I don't know why \x1b[K is used, but as far as I can see, it is useless.