https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81610

            Bug ID: 81610
           Summary: bogus fix-it hint for a call to an undeclared
                    function: for
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gcc dot gnu.org
  Target Milestone: ---

When G++ detects a call to an undeclared function it prints an error message
which may include a fix-it hint with a suggestion for an alternative.  That's
helpful when the alternative is a function with a similar name.  It's not
helpful when the alternative is not a function that can be called as in the
case below where the suggestion is obviously bogus.  G++ should avoid
suggesting symbols that cannot be used in the context in which the original
name is used.

$ cat t.C && gcc -S -Wall -Wextra -Wpedantic t.C
void f (void *p)
{
  forget (p);
}
t.C: In function ‘void f(void*)’:
t.C:3:3: error: ‘forget’ was not declared in this scope
   forget (p);
   ^~~~~~
t.C:3:3: note: suggested alternative: ‘for’
   forget (p);
   ^~~~~~
   for

Reply via email to