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

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
PowerPC
OS
Mac OS X
Creation time
2006-03-12T13:53:00Z
Last change time
2015-06-09T05:15:05Z
Keywords
ice-on-valid-code
Assigned to
dvdfrdmn
Creator
braddr

Comments

Comment #0 by braddr — 2006-03-12T13:53:10Z
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; }
Comment #1 by braddr — 2006-03-21T01:28:04Z
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?
Comment #2 by dvdfrdmn — 2006-04-19T22:32:15Z
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.
Comment #3 by braddr — 2006-05-30T02:42:40Z
fixed in gdc 0.18
Comment #4 by thomas-dloop — 2006-12-30T20:10:03Z