Implicit conversion between calling conventions

Daniel Murphy yebbliesnospam at gmail.com
Mon Feb 8 06:15:01 PST 2010


The following code compiles (dmd2.040) but segfaults when run.
In my opinion it should be illegal to implicitly convert from one calling convention to another.
The case where either calling convention will produce the same code could still be allowed, but I doubt there will be much (if any) use for it.

import std.stdio;

extern(C) void foo(real r)
{
	writeln("foo");
}
extern(D) void bar(real r)
{
	writeln("bar");
}

void main()
{
	auto ptr = &foo;
	ptr(0.L);
	ptr = &bar;
	ptr(0.L);
}



More information about the Digitalmars-d mailing list