Movatterモバイル変換


[0]ホーム

URL:


Issue 1 - WG21 CWG Issues
Title
What if two using-declarations refer to the same function but the declarations introduce different default-arguments?
Status
tc1
Section
9.3.4.7 [dcl.fct.default]
Submitter
Bill Gibbons

Created on1998-10-24.00:00:00 last changed277 months ago

Messages

msg24 (view)
Date: 2004-09-10.00:00:00

6.4 [basic.scope] paragraph 4says:

Given a set of declarations in a single declarative region, each ofwhich specifies the same unqualified name,
  • they shall all refer to the same entity, or all refer to functions ...
9.3.4.7 [dcl.fct.default] paragraph 9says:
When a declaration of a function is introduced by way of ausing-declaration (9.10 [namespace.udecl]),any default argument information associated with thedeclaration is imported as well.
This is not really clear regarding what happens in the following case:
    namespace A {            extern "C" void f(int = 5);    }    namespace B {            extern "C" void f(int = 7);    }    using A::f;    using B::f;    f(); // ???
Proposed resolution (10/00):

Add the following at the end of 12.2.4 [over.match.best]:

If the best viable function resolves to a function for whichmultiple declarations were found, and if at least two of thesedeclarations — orthe declarations they refer to in the case ofusing-declarations — specifya default argument that made the function viable, the program is ill-formed.[Example:
    namespace A {
       extern "C" void f(int = 5);
    }
    namespace B {
       extern "C" void f(int = 5);
    }

    using A::f;
    using B::f;

    void use() {
       f(3);      // OK, default argument was not used for viability
       f();       // Error: found default argument twice
    }

  —end example]

History
DateUserActionArgs
2003-04-25 00:00:00adminsetstatus: dr -> tc1
2000-11-18 00:00:00adminsetstatus: ready -> dr
2000-05-21 00:00:00adminsetstatus: drafting -> ready
1998-10-24 00:00:00admincreate

[8]ページ先頭

©2009-2026 Movatter.jp