1

There's a function that's not working and I don't understand why, and DBX isn't helping. Below is what I'm talking about.

(dbx 12) print ((CCFundExpenseObject *)s1)->GetFundBranchGroup()
((class CCFundExpenseObject *) s1)->GetFundBranchGroup() = -2019
(dbx 13) print (*((CCFundExpenseObject *)s1)).GetFundBranchGroup()
(*((class CCFundExpenseObject *) s1)).GetFundBranchGroup() = 1

Logically, both lines should have the same result, right?

If you want more context, here's an explanation of the code:

  • GetFundBranchGroup() returns a short stored in CCFundExpenseObject. That's it.
  • s1 is a void*
Jesse Jashinsky
  • 10,313
  • 6
  • 38
  • 63
  • IMO, your *context* is adding to the confusion. How is it related to the print statements in the debugger you've shown above? And why all the `void *`s and casting; you're writing C++, not C! If `GetFundBranchGroup()` has side effects it is entirely possible for the first invocation to return `-2019` and the second `1`. There's not enough context here to answer your question. – Praetorian Apr 19 '13 at 23:12
  • No side effects; 'GetFundBranchGroup()' simply returns a short. And yes, 'void *' is more C, which probably says how long ago this code was written. – Jesse Jashinsky Apr 19 '13 at 23:22

0 Answers0