[Bug c++/13700] New: Member function definition in non-enclosing scope

grigory dot zagorodnev at intel dot com gcc-bugzilla@gcc.gnu.org
Thu Jan 15 16:15:00 GMT 2004


The C++ Standard says that "a member function definition that appears outside 
of the class definition shall appear in a namespace scope enclosing the class 
definition" [9.3/2]

At the same time g++ compiler allows successful compilation of the code listed 
below. That seems to be a standard violation.

	struct C {
		void foo();
	};
	
	namespace B {
		void C::foo(){};
	}

Note: namespace B has no definition of C, so C::foo may not be defined in it.

-- 
           Summary: Member function definition in non-enclosing scope
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: grigory dot zagorodnev at intel dot com
                CC: gcc-bugs at gcc dot gnu dot org
  GCC host triplet: i686-redhat-linux


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



More information about the Gcc-bugs mailing list