www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - ambiguous variadic function call not rejected by dmd 0.131 (win32)

reply zwang <nehzgnaw gmail.com> writes:
<code>
void f(...){}
void f(int i, ...){}
void f(int i, int j){}
void main(){	
     f(0, 0);	
}
</code>

The call "f(0,0)" matches all three definitions of function f, which 
should not compile.
Sep 19 2005
next sibling parent Derek Parnell <derek psych.ward> writes:
On Tue, 20 Sep 2005 14:20:52 +0800, zwang wrote:

 <code>
 void f(...){}
 void f(int i, ...){}
 void f(int i, int j){}
 void main(){	
      f(0, 0);	
 }
 </code>
 
 The call "f(0,0)" matches all three definitions of function f, which 
 should not compile.
But using the rules for specialization, the f(0,0) is an exact match so it compiles. -- Derek (skype: derek.j.parnell) Melbourne, Australia 20/09/2005 4:48:28 PM
Sep 19 2005
prev sibling parent Derek Parnell <derek psych.ward> writes:
On Tue, 20 Sep 2005 14:20:52 +0800, zwang wrote:

 <code>
 void f(...){}
 void f(int i, ...){}
 void f(int i, int j){}
 void main(){	
      f(0, 0);	
 }
 </code>
 
 The call "f(0,0)" matches all three definitions of function f, which 
 should not compile.
But a more problematic issue is that "f(0, 'a')" fails to compile. test.d(5): function test.f called with argument types: (int,char) matches both: test.f(...) and: test.f(int,int) And I can't work out how to get it to call 'f(int, ...)' if I want to. -- Derek (skype: derek.j.parnell) Melbourne, Australia 20/09/2005 4:58:35 PM
Sep 20 2005