Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!snorkelwacker.mit.edu!bloom-beacon!eru!hagbard!sunic!isgate!krafla!aries From: aries@rhi.hi.is (Mimir Reynisson) Newsgroups: comp.sys.mac.programmer Subject: Re: C++ method overriding Message-ID: <2844@krafla.rhi.hi.is> Date: 27 Feb 91 18:02:43 GMT References: <2831@krafla.rhi.hi.is> <1991Feb25.214458.11837@ux1.cso.uiuc.edu> Organization: University of Iceland Lines: 67 In reference to my previous follow-up: I discovered MPW C 3.2b3a100 to generate incorrect code for the following example: #include main() { Rect h; Check(h.left); // this is ok Check((h.left + 1)); // this is ok Check((short)h.left + 1); // this is ok Check((short)(h.left + 1)); // we get incorrect code here! } What I did was to compile this from the shell and then to call dumpobj to analyze the code. Here is the dump I made: 00000000: 4E56 FFF8 'NV..' LINK A6,#$FFF8 00000004: 302E FFFA '0...' MOVE.W -$0006(A6),D0 00000008: 48C0 'H.' EXT.L D0 0000000A: 2F00 '/.' MOVE.L D0,-(A7) 0000000C: 4EBA 0000 'N...' JSR Check 00000010: 302E FFFA '0...' MOVE.W -$0006(A6),D0 00000014: 48C0 'H.' EXT.L D0 00000016: 5280 'R.' ADDQ.L #$1,D0 00000018: 2F00 '/.' MOVE.L D0,-(A7) 0000001A: 4EBA 0000 'N...' JSR Check 0000001E: 302E FFFA '0...' MOVE.W -$0006(A6),D0 00000022: 48C0 'H.' EXT.L D0 00000024: 5280 'R.' ADDQ.L #$1,D0 00000026: 2F00 '/.' MOVE.L D0,-(A7) 00000028: 4EBA 0000 'N...' JSR Check Here is the incorrect part: 0000002C: 302E FFFC '0...' MOVE.W -$0004(A6),D0 ???? wrong member 00000030: 5240 'R@' ADDQ.W #$1,D0 00000032: 48C0 'H.' EXT.L D0 00000034: 2F00 '/.' MOVE.L D0,-(A7) 00000036: 4EBA 0000 'N...' JSR Check 0000003A: 4E5E 'N^' UNLK A6 0000003C: 4E75 'Nu' RTS 0000003E: 846D 6169 '.mai' OR.W $6169(A5),D2 00000042: 6E00 0000 'n...' BGT *+$0002 I think I could live with this situation if it weren't for the fact that MPW C++ generates C code that looks like: MoveTo((short )(h. left +1), (short )h. top); Which means that C gets it wrong and I have to do my calculations before calling my function.s If I havn't said it already then I'll do so now: this only happens in argument section of a function call not in assignments (although I haven't tried to do an assignment in the argument section .. um I wonder if that'd work ..) Anyway there you have it ... -MymR