This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/86102] Include argument name in warning
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 11 Jun 2018 11:06:51 +0000
- Subject: [Bug c/86102] Include argument name in warning
- Auto-submitted: auto-generated
- References: <bug-86102-4@http.gcc.gnu.org/bugzilla/>
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).