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++/13699] New: Extern "C" routine in different namespaces is not the same entity


G++ compiler does not issue any error on the standard-violating code listed 
below, regardless of pedantry level.

	namespace A {
	    extern "C" void foo() throw();
	}
	extern "C" void foo();


Details
-------
According to the C++ Standard, "two declarations for a function with C language 
linkage with the same function name... that appear in different namespace 
scopes refer to the same function" [7.5/6] 

Next, "if any declaration of a function has an exception-specification, all 
declarations, including the definition.., of that function shell have an 
exception-specification with the same set of type-ids" [15.4/2]

In our example, two declarations of the same extern "C" routine 'foo' have 
different exception-specifications. This is the C++ standard violation.

However, G++ compiler silently compiles this code. This makes to think 
extern "C" routine in different namespaces is not the same entity for g++.

-- 
           Summary: Extern "C" routine in different namespaces is not the
                    same entity
           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=13699


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