[Issue 1814] DMD/GDC does not prevent typedef violations

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Feb 3 10:06:08 PST 2008


http://d.puremagic.com/issues/show_bug.cgi?id=1814





------- Comment #1 from default_357-line at yahoo.de  2008-02-03 12:06 -------
(In reply to comment #0)
> The spec says the following about typedefs:
> 
> "A typedef or enum can be implicitly converted to its base type, but going the
> other way requires an explicit conversion."
> 
> Why, then, does the following work (on the most recent DMD and GDC)?
> 
> import std.stdio;
> typedef int Foo;
> void test(Foo foo) { }
> void main() { test(3); /*ILLEGAL!*/ Foo f = cast(Foo) 2; writefln(f+3); /*ALSO
> ILLEGAL*/ }

Ignore the second one, please, I understand what happens. The first one is
still wrong, though. 
>  --downs
> 

 --downs :)


-- 



More information about the Digitalmars-d-bugs mailing list