[Bug 43] enable-checking error found in std/socket.d

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Mar 20 23:28:05 PST 2006


http://d.puremagic.com/bugzilla/show_bug.cgi?id=43





------- Comment #1 from braddr at 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?


-- 




More information about the D.gnu mailing list