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

            Bug ID: 85690
           Summary: missing suggested header for std-qualified names
           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: ---

For the test case below, GCC suggests to include <cstddef> for the unqualified
reference to ptrdiff_t but it doesn't offer a similar suggestion for the
reference to std::size_t.  It should suggest the header to include for both.

In addition, since the <cxxx> kind of C headers need not define symbols in the
global namespace (and not implementations do define them there), for
unqualified references to such symbols GCC should suggest the traditional
<xxx.h> header, and the <cxxx> kind only for std-qualified references.

$ cat b.c && gcc -O3 -S -Wall -Wextra -Wpedantic -xc++ b.c
void f (ptrdiff_t);

void g (std::size_t);
b.c:1:18: error: variable or field ‘f’ declared void
 void f (ptrdiff_t);
                  ^
b.c:1:9: error: ‘ptrdiff_t’ was not declared in this scope
 void f (ptrdiff_t);
         ^~~~~~~~~
b.c:1:9: note: ‘ptrdiff_t’ is defined in header ‘<cstddef>’; did you forget to
‘#include <cstddef>’?
+#include <cstddef>
 void f (ptrdiff_t);
         ^~~~~~~~~
b.c:3:20: error: variable or field ‘g’ declared void
 void g (std::size_t);
                    ^
b.c:3:14: error: ‘size_t’ is not a member of ‘std’
 void g (std::size_t);
              ^~~~~~

Reply via email to