This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/86102] Include argument name in warning


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).

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]