Ambiguity in friend function declarations?

28 views
Skip to first unread message

Serge Pavlov

unread,
Aug 22, 2016, 11:47:21 AM8/22/16
to ISO C++ Standard - Discussion
If a function declared in global namespace returns value of class or enum type, there is apparent ambiguity if this function is declared as a friend of some class defined in a namespace. See example:

class A {};

A func();

namespace N {
  class C {
    friend A :: func();
  };
}

gcc, cland and icc all reject the friend function declaration, because the try to interpret 'A::' as a nested name specifier. It would however be a valid code if '::' were treated as a global scope specifier in function declarator.

The question is inspired by clang problem report https://llvm.org/bugs/show_bug.cgi?id=28422, which considers the case of enum, but the problem is the same.

Is there anything in the Standard that prescribes such interpretation?

Richard Smith

unread,
Aug 22, 2016, 3:46:36 PM8/22/16
to std-dis...@isocpp.org

Serge Pavlov

unread,
Aug 23, 2016, 1:02:47 AM8/23/16
to std-dis...@isocpp.org
It is exactly what I need.
Thank you very much!

--Serge

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-discussion+unsubscribe@isocpp.org.
To post to this group, send email to std-dis...@isocpp.org.
Visit this group at https://groups.google.com/a/isocpp.org/group/std-discussion/.

Reply all
Reply to author
Forward
0 new messages