www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Implicit conversion between calling conventions

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);
}
Feb 08 2010