[Bug c/86102] Include argument name in warning
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Jun 11 11:06:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86102
--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jonny Grant from comment #2)
> There is no benefit from displaying 'value' '"test"' or 'str' ?
Right. In this case they're short strings, but the arguments to a function can
be arbitrary expressions:
printf("%zu %zu %zu", sizeof(C)+sizeof(D)*2, x.func1()+y.func2(), a-b);
What's the "argument name" here?
The caret diagnostics can highlight the expression, which is preferable to
trying to "name" something without a name, or trying to reconstruct the
expression to print:
... but argument 3 'sizeof(C)+sizeof(D)*2' has type ‘char *’
One of the major advantages of caret diagnostics is avoiding printing arbitrary
expressions in diagnostic text (especially after they've been parsed and munged
into an AST that doesn't necessarily resemble the original code).
More information about the Gcc-bugs
mailing list