digitalmars.D.bugs - [Issue 9795] New: cast fails for C's forward referenced structure pointer
- d-bugmail puremagic.com (57/57) Mar 23 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9795
- d-bugmail puremagic.com (23/23) Oct 01 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9795
http://d.puremagic.com/issues/show_bug.cgi?id=9795 Summary: cast fails for C's forward referenced structure pointer Product: D Version: D2 Platform: x86 OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: kodlists-dlang yahoo.com 09:59:23 PDT --- With DMD32 D Compiler v2.062, $ cat libA.d module libA; extern (C) { struct Opaque; // forward reference Opaque* getObject(); } $ cat libB.d module libB; extern (C) { struct Opaque; // forward reference void doAction(Opaque *); } $ cat bug.d import libA, libB; int main(string[] args) { auto opaque = libA.getObject(); libB.doAction(cast(libB.Opaque *)opaque); return 0; } $ rdmd bug.dlibB.d(5): Error: struct libB.Opaque unknown size libB.d(5): Error: struct libB.Opaque no size yet for forward reference libB.d(5): Error: struct libB.Opaque unknown size libB.d(5): Error: struct libB.Opaque no size yet for forward reference libA.d(5): Error: struct libA.Opaque unknown size libA.d(5): Error: struct libA.Opaque no size yet for forward reference Failed: 'dmd' '-v' '-o-' 'bug.d' '-I.' $ If we declare Opaque in a separate file and import it in libA and libB, then there is no compiler error. Also if we remove the cast in bug.d, the error message would be: bug.d(6): Error: function libB.doAction (Opaque*) is not callable using argument types (Opaque*) bug.d(6): Error: cannot implicitly convert expression (opaque) of type Opaque* to Opaque* The compiler should have qualified Opaque so that it is easier to understand that it cannot convert libA.Opaque* to libB.Opaque* -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 23 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9795 Kenji Hara <k.hara.pg gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |DUPLICATE This is a dup of bug 10451. With 2.064 git-head, the OP code correctly reports link-time errors. $ dmd libA.d libB.d bug.d DMD v2.064 DEBUG OPTLINK (R) for Win32 Release 8.00.12 Copyright (C) Digital Mars 1989-2010 All rights reserved. http://www.digitalmars.com/ctg/optlink.html libA.obj(libA) Error 42: Symbol Undefined _getObject libA.obj(libA) Error 42: Symbol Undefined _doAction --- errorlevel 2 *** This issue has been marked as a duplicate of issue 10451 *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 01 2013