Skip navigation.
 
mlRe: Strange problem when not declaring the functions in interface
FROM : Shawn Erickson
DATE : Mon Apr 18 22:34:05 2005

On Apr 18, 2005, at 1:08 PM, Pradeep Kumar wrote:

>  See the results of the last two statements. 410 and 1660. Why is this
> happening?


Well I assume you noted the warnings...

/Users/shawnce/Development/TestCocoaProject/MyObject.m:27: warning:
`MyObject' may not respond to `-foo2'
/Users/shawnce/Development/TestCocoaProject/MyObject.m:27: warning:
cannot find method `-foo2'; return type `id' assumed
/Users/shawnce/Development/TestCocoaProject/MyObject.m:27: warning:
assignment makes integer from pointer without a cast

In the following r2 contains the value returned by [self foo2] (part I
copy and pasted) and r0 contains the value of "i" before and after the
addition (i + [self foo2]). Also optimization was disabled in the
following.

With things defined to return 'int'...

   addis r2,r31,ha16(L_OBJC_SELECTOR_REFERENCES_1-"L-0000000005$pb")
   la r2,lo16(L_OBJC_SELECTOR_REFERENCES_1-"L-0000000005$pb")(r2)
   lwz r3,120(r30)
   lwz r4,0(r2)
   bl L_objc_msgSend$stub
   mr r2,r3
   lwz r0,72(r30)
   add r0,r0,r2
   stw r0,72(r30)
   .stabd    68,0,28
   addis r3,r31,ha16(LC11-"L-0000000005$pb")
   la r3,lo16(LC11-"L-0000000005$pb")(r3)
   lwz r4,72(r30)
   bl L_NSLog$stub

...and with things not defined, hence 'id' is assumed...

   addis r2,r31,ha16(L_OBJC_SELECTOR_REFERENCES_1-"L-0000000005$pb")
   la r2,lo16(L_OBJC_SELECTOR_REFERENCES_1-"L-0000000005$pb")(r2)
   lwz r3,120(r30)
   lwz r4,0(r2)
   bl L_objc_msgSend$stub
   mr r2,r3
   lwz r0,72(r30)
   slwi r0,r0,2                  <<<<<<<<< difference
   add r0,r2,r0
   stw r0,72(r30)
   .stabd    68,0,28
   addis r3,r31,ha16(LC11-"L-0000000005$pb")
   la r3,lo16(LC11-"L-0000000005$pb")(r3)
   lwz r4,72(r30)
   bl L_NSLog$stub

So in the later it is shifting left by 2 the value in "i" before doing
the addition.

At the moment I don't know why it would be doing the shift (medicated
because of neck injury so I may missing something obvious).

-Shawn

Related mailsAuthorDate
mlStrange problem when not declaring the functions in interface Pradeep Kumar Apr 18, 22:08
mlRe: Strange problem when not declaring the functions in interface Shawn Erickson Apr 18, 22:34
mlRe: Strange problem when not declaring the functions in interface Ivan S. Kourtev Apr 18, 22:36
mlRe: Strange problem when not declaring the functions in interface Daniel DeCovnick Apr 19, 05:34