Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7955 Discussions

Friend declaration for sibling inner class causes warning

Marco_P_
Beginner
369 Views


The following code causes a bogus warning:

 ~ > cat /tmp/main.cpp
template <typename T>
class Parent {
  class A {};
  class B {
    friend class Parent<T>::A;
  };
};
 ~ > icc -c /tmp/main.cpp
/tmp/main.cpp(5): warning #135: class template "Parent<T>" has no member "A"
      friend class Parent<T>::A;
                              ^

However it's perfectly legal C++ (AFAICT), and there are no warnings under either GCC 4.8.5 or Clang 3.7.0.

0 Kudos
1 Reply
Judith_W_Intel
Employee
369 Views

 

Yes it looks like we inadvertently give a warning on the above.

We were trying to catch this case below -- which g++ and Clang allow without a warning:

g++ and Microsoft allow a friend declaration that refers to an undeclared
member of a prototype instantiation.  For example:

  template <class T> struct A {
    struct B {
      friend void A::f();
    };
  };

I have entered a bug report (DPD200380380) for us to distinguish between these two cases.

Thanks for letting us know.

Judy

 

0 Kudos
Reply