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

            Bug ID: 99404
           Summary: Diagnostics for undeclared members of a namespace
                    don't say "namespace"
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: enhancement
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
  Target Milestone: ---

#include <chrono>
#include <future>
int main()
{
  std::this_thread::sleep_until(std::chrono::system_clock::now());
}

This invalid program gives:

ns.C: In function 'int main()':
ns.C:5:21: error: 'sleep_until' is not a member of 'std::this_thread'
    5 |   std::this_thread::sleep_until(std::chrono::system_clock::now());
      |                     ^~~~~~~~~~~

It might be helpful to casual C++ programmers if it was clear that
'std::this_thread' is a namespace, and not a class type or global variable e.g.

ns.C:5:21: error: 'sleep_until' is not a member of namespace 'std::this_thread'


Minimal example:

namespace N { }
void f() {
  using N::a;
  N::b();
}

ns2.C: In function ‘void f()’:
ns2.C:3:12: error: ‘a’ has not been declared in ‘N’
    3 |   using N::a;
      |            ^
ns2.C:4:6: error: ‘b’ is not a member of ‘N’
    4 |   N::b();
      |      ^

Also, is there a reason these two diagnostics are worded differently?


Clang says:

ns2.C:3:12: error: no member named 'a' in namespace 'N'
  using N::a;
        ~~~^
ns2.C:4:6: error: no member named 'b' in namespace 'N'
  N::b();
  ~~~^
2 errors generated.


And EDG says:

"ns2.C", line 3: error: namespace "N" has no member "a"
    using N::a;
             ^

"ns2.C", line 4: error: namespace "N" has no member "b"
    N::b();
       ^

2 errors detected in the compilation of "ns2.C".

Reply via email to