Thread overview
[Bug 43] New: enable-checking error found in std/socket.d
Mar 12, 2006
d-bugmail
Mar 21, 2006
d-bugmail
Apr 20, 2006
d-bugmail
May 30, 2006
d-bugmail
March 12, 2006
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;
}


-- 

March 21, 2006
http://d.puremagic.com/bugzilla/show_bug.cgi?id=43





------- Comment #1 from braddr@puremagic.com  2006-03-21 01:28 -------
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?


-- 

April 20, 2006
http://d.puremagic.com/bugzilla/show_bug.cgi?id=43


dvdfrdmn@users.sf.net changed:

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




------- Comment #2 from dvdfrdmn@users.sf.net  2006-04-19 22:32 -------
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.


-- 

May 30, 2006
http://d.puremagic.com/bugzilla/show_bug.cgi?id=43


braddr@puremagic.com changed:

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




------- Comment #3 from braddr@puremagic.com  2006-05-30 02:42 -------
fixed in gdc 0.18


--