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

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


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

           Summary: DMD/GDC does not prevent typedef violations
           Product: D
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: accepts-invalid
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: default_357-line at yahoo.de


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*/ }

This basically makes typedef no better than alias.
Looking forward to a fix,

 --downs


-- 



More information about the Digitalmars-d-bugs mailing list