This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/60611] New: friend function declaration rejected when the namespace in which it is declared is not explicitely specified in the declaration


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60611

            Bug ID: 60611
           Summary: friend function declaration rejected when the
                    namespace in which it is declared is not explicitely
                    specified in the declaration
           Product: gcc
           Version: 4.7.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nicolas.bertolotti at mathworks dot fr

Created attachment 32419
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=32419&action=edit
Source file to reproduce the issue

If you compile the following piece of code using g++ (4.7.2):
"
class class1; 

namespace ns1 { 

class class2; 
class class3; 
}

ns1::class3 *func(ns1::class2 * cfg, const class1 * def); 

namespace ns1 { 

class class4 { 
#ifdef WORKAROUND
friend ns1::class3 *(::func)(ns1::class2 * cfg, const class1 * def);
#else
friend class3 *(::func)(class2 * cfg, const class1 * def); 
#endif
}; 
}
" (also attached)
you get the following:
$ g++ -c test.cpp
test.cpp:17:25: error: âfuncâ is neither function nor member function; cannot
be declared friend
test.cpp:17:23: error: expected â;â at end of member declaration
test.cpp:17:32: error: expected â)â before â*â token

Now, if you explicitely add the namespaces as they appear in the initial
declaration (add -DWORKAROUND), the compilation succeeds.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]