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

            Bug ID: 77829
           Summary: Bad fix-it for nested-name-specifier
           Product: gcc
           Version: 6.2.1
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
  Target Milestone: ---

namespace detail {
  int _foo(int i) { return i; }
}

void bar(int i) {
  detail::foo(i);
}

This says:

fixit.cc: In function ‘void bar(int)’:
fixit.cc:6:3: error: ‘foo’ is not a member of ‘detail’
   detail::foo(i);
   ^~~~~~
fixit.cc:6:3: note: suggested alternative: ‘bool’
   detail::foo(i);
   ^~~~~~
   bool


There are two problems here. Firstly, the range info for the rich location
suggests replacing "detail" when it should be "foo". The patch generated by
-fdiagnostics-generate-patch is:

--- fixit.cc
+++ fixit.cc
@@ -3,5 +3,5 @@
 }

 void bar(int i) {
-  detail::foo(i);
+  bool::foo(i);
 }


Secondly, detail::_foo should be a better match for detail::foo than
detail::bool (which wouldn't be valid, because bool is not an identifier).

Reply via email to