https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65119
Bug ID: 65119
Summary: -fmessage-length= counts control characters when
wrapping the caret line
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: manu at gcc dot gnu.org
struct {
int y;
} x;
#define FOO
x*x
void foo()
{
FOO;
}
~/test1/220306M/build/gcc/cc1 test.c -fmessage-length=10
-fdiagnostics-color=always
foo
test.c: In
function
‘foo’
:
test.c:4:144: error: invalid
operands
to
binary
*
(have
‘struct
<anonymous>’
and
‘struct
<anonymous>’
)
x*x
^
test.c:7:3: note: in
expansion
of
macro
‘FOO’
FOO;
^
The reason is that pp_string()
https://github.com/gcc-mirror/gcc/blob/master/gcc/diagnostic.c#L384 counts
control characters (such as the color codes) when deciding whether to wrap
around, however those characters are not normally visible thus they produce a
strange effect. In general, the whole pretty-printer wrapping is oblivious to
the color codes, which is likely to produce excessive wrapping when using
-fmessage-length=.