This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/13699] New: Extern "C" routine in different namespaces is not the same entity
- From: "grigory dot zagorodnev at intel dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 15 Jan 2004 15:16:42 -0000
- Subject: [Bug c++/13699] New: Extern "C" routine in different namespaces is not the same entity
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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