www.digitalmars.com         C & C++   DMDScript  

D.gnu - [Bug 43] New: enable-checking error found in std/socket.d

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/bugzilla/show_bug.cgi?id=43

           Summary: enable-checking error found in std/socket.d
           Product: GDC
           Version: 0.17
          Platform: Macintosh
        OS/Version: Mac OS X
            Status: NEW
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P2
         Component: glue layer
        AssignedTo: dvdfrdmn users.sf.net
        ReportedBy: braddr puremagic.com


Reduced test case:

module std.socket;

struct protoent {
    int p_proto;
}

enum ProtocolType
{
    IPV6 = 1,
}

void populate(protoent* proto)
{
    ProtocolType type = cast(ProtocolType)proto.p_proto;
}


-- 
Mar 12 2006
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/bugzilla/show_bug.cgi?id=43






I believe the problem lies in Expression::castTo().

Expression::castTo(this=*&*proto + (0), type=int, t=ProtocolType)
Returning type: ProtocolType
Returning expression: *&*proto + (0)

Expression::castTo(this=*proto + (0), type=ProtocolType, t=ProtocolType)
Returning type: ProtocolType
Returning expression: *proto + (0)

The dmd front end considers types to be the same if their base types are the
same.  However, gcc considers int and enum to be different when checking types.

so, something like:

+    orig = type; 
     type = type->toBasetype();
+    if ((tb->ty   == Tenum && orig->isintegral()) ||
+        (orig->ty == Tenum && tb  ->isintegral()))
+    {
+        e = new CastExp(loc, e, orig);
+    }
+    else if (tb != type)
-    if (tb != type)

... allows the above code to compile.  The resulting expression looks like:
Returning type: ProtocolType
Returning expression: cast(ProtocolType)*proto + (0)

The expression dumper should be adding a () around the *proto + (0) since it
looks like the cast doesn't apply to the whole thing here but it does.

David, does this seem like the right direction to you?


-- 
Mar 20 2006
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/bugzilla/show_bug.cgi?id=43


dvdfrdmn users.sf.net changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED





The enum/int inconsistency is only a problem when there is an indirection
involved.  This can be fixed in the glue layer by casting the pointer used in
the indirection.


-- 
Apr 19 2006
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/bugzilla/show_bug.cgi?id=43


braddr puremagic.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED





fixed in gdc 0.18


-- 
May 30 2006