[Issue 1069] New: No error on type mismatch with varargs
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Mar 19 12:40:36 PDT 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1069
Summary: No error on type mismatch with varargs
Product: D
Version: 1.009
Platform: PC
OS/Version: Windows
Status: NEW
Keywords: accepts-invalid
Severity: normal
Priority: P2
Component: DMD
AssignedTo: bugzilla at digitalmars.com
ReportedBy: sean at f4.ca
If a vararg function is defined like so:
void add( void delegate()[] procs... )
the compiler will not complain when delegates are added without the leading
address qualifier, but an error will occur when the delegate is run in some
cases. Here is an example:
class C
{
this()
{
add( fn );
}
void fn()
{
printf( "hello\n" );
}
}
class Elem
{
void delegate() proc;
Elem next;
}
Elem first;
void add( void delegate()[] procs... )
{
foreach( p; procs )
{
auto e = new Elem;
e.proc = p;
e.next = first;
first = e;
}
}
void call()
{
for( Elem e = first; e; e = e.next )
e.proc();
}
void main()
{
auto val = new C;
call();
}
C:\code\src\d\test>dmd test
c:\bin\dmd\bin\..\..\dm\bin\link.exe test,,,user32+kernel32/noi;
C:\code\src\d\test>test
Access Violation
C:\code\src\d\test>
--
More information about the Digitalmars-d-bugs
mailing list