Movatterモバイル変換


[0]ホーム

URL:


Issue 101 - WG21 CWG Issues
Title
Redeclaration of extern "C" names via using-declarations
Status
tc1
Section
9.10 [namespace.udecl]
Submitter
Mike Miller

Created on1999-03-10.00:00:00 last changed277 months ago

Messages

msg78 (view)
Date: 1999-04-15.00:00:00

Proposed Resolution (10/99):As suggested.

msg77 (view)
Date: 2022-11-20.07:54:16

Consider the following:

    extern "C" void f();    namespace N {        extern "C" void f();    }    using N::f;
According to9.10 [namespace.udecl]paragraph 11, theusing-declaration is an error:
If a function declaration in namespace scope or blockscope has the same name and the same parameter typesas a function introduced by ausing-declaration, theprogram is ill-formed.
Based on the context (9.10 [namespace.udecl]paragraph 10 simply reiterates the requirementsof6.4 [basic.scope]), one might wonder ifthe failure to exemptextern "C"functions was intentional or an oversight. After all, there isonly one functionf() involved, because it'sextern "C", soambiguity is not a reason to prohibit theusing-declaration.

This also breaks the relatively strong parallel betweenextern "C"functions and typedefs established in our discussion ofCore issue 14in Santa Cruz. There the question was forusing-directives:

    typedef unsigned int size_t;    extern "C" int f();    namespace N {        typedef unsigned int size_t;        extern "C" int f();    }    using namespace N;    int i = f();        // ambiguous "f"?    size_t x;           // ambiguous "size_t"?
We decided for both that there was no ambiguity because eachpair of declarations declares the same entity. (According to6.1 [basic.pre] paragraph 3,a typedef name is not an entity, but a type is; thus thedeclarations ofsize_t declare the same entity "unsigned int".)

In the context ofusing-declarations, there is no explicitextension of the restrictions in 6.4 [basic.scope]paragraph 4 except as noted above for function declarations; thus the parallelscenario for a typedef is not ill-formed:

    typedef unsigned int size_t;    namespace N {        typedef unsigned int size_t;    };    using N::size_t;        // okay, both declarations                            // refer to the same entity
I think the first sentence of9.10 [namespace.udecl]paragraph 11 ought to be rewritten as:
If a function declaration in namespace scope or blockscope has the same name and the same parameter typesas a function introduced by ausing-declaration,and the declarations do not declare the same function, theprogram is ill-formed.

Proposed Resolution (10/99):As suggested.

History
DateUserActionArgs
2003-04-25 00:00:00adminsetstatus: dr -> tc1
2000-02-23 00:00:00adminsetstatus: ready -> dr
1999-09-14 00:00:00adminsetmessages: +msg78
1999-03-10 00:00:00admincreate

[8]ページ先頭

©2009-2026 Movatter.jp