Hi,
the suggestions are cool and they obviously can't be always correct.
I guess it matches this against different valid identifiers and somehow
counting a score for these and showing the identifier with the highest
score. I did not found anything about the "how" in the GCC annotation.
But I do wonder if the following is the ideal:
/media/dev/gnu-cobol-2.0/cobc/cobc.c: In function 'process_command_line':
/media/dev/gnu-cobol-2.0/cobc/cobc.c:3010:6: error: 'cb_fatal_error'
undeclared (first use in this function); did you mean 'cob_fatal_error'?
if (cb_fatal_error) {
^~~~~~~~~~~~~~
cob_fatal_error
OK, so we used a wrong variable name. But GCC suggests a function
address...
The definition of cob_fatal_error is
void
cob_fatal_error(const int fatal_error)
declared in an included header file as
extern void cob_fatal_error (const int) __attribute__((noreturn));
changing it as suggested raises
/media/dev/gnu-cobol-2.0/cobc/cobc.c: In function 'process_command_line':
/media/dev/gnu-cobol-2.0/cobc/cobc.c:3010:6: warning: the address of
'cob_fatal_error' will always evaluate as 'true' [-Waddress]
if (cob_fatal_error) {
^~~~~~~~~~~~~~~
(I first thought this warning was wrong, too as
__attribute__((noreturn)) explicit tells the compiler that this function
will never return, but it is actually using the function address...)
The correct version is
if (fatal_error) {
and the definition of fatal_error, local to cobc.c is:
int fatal_error = 0;
Suggestions for this hard to always guess right area:
* document how the suggestion is calculated, link this in places where
this feature is referenced like https://gcc.gnu.org/gcc-7/changes.html
* don't suggest a function address if any other possible candidates exist
* give local variables a higher score
Thank you for this wonderful and evolving compiler!
Simon
I'm not subscribed to the list, please answer directly (CCing the list
of course), otherwise I can't read your response.
Thank you.