• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: variable weirdness
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: variable weirdness


  • Subject: Re: variable weirdness
  • From: Erik Grumstrup <email@hidden>
  • Date: Fri, 10 Feb 2006 23:33:11 -0600


As suggested, showing the code would help, but I can give you a general
hint. Switching between debug & build changes memory layout, and I've seen
similar bugs in my code caused by my not setting a variable correctly
somewhere, and its memory just coincidentally holding a correct (or at least
non-crashing) value left over from some other function invocation. You'd
think at first the odds against this would be ridiculously large, but
actually, considering the stack and how things are laid out, it's not that
uncommon for an uninitialized variable to have a reasonable-looking value.

ok...a bit of abbreviated code, though I am unsure it will reveal anything...


main()
{
double my_a[13];

my_a[1]=109789.99;
etc..

spec_calc_pred(my_a[1],my_a[2],.....);

}
**************************************************
void spec_calc_pred(double a, double b.....)
{
printf("%f\n",a);

(further code)
}

Every time, the variable is shown as having a value of 0.0 and any expressions in the function are evaluated to 0 regardless of the variable name. The header file all checked out, and I have combed through the code for unintentional reassignments and came up with nothing. In fact, I have temporarily solved the problem by simply putting a dummy variable as the first argument of the function and having the 'a' variable as the second. The program executes perfectly when I do this which strikes me as very odd. Hope this helps...and thanks.

Erik Grumstrup
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: variable weirdness
      • From: Scott Ribe <email@hidden>
    • Re: variable weirdness
      • From: Cameron Hayne <email@hidden>
References: 
 >Re: variable weirdness (From: Scott Ribe <email@hidden>)

  • Prev by Date: Re: Release build won't run
  • Next by Date: Re: external declares
  • Previous by thread: Re: variable weirdness
  • Next by thread: Re: variable weirdness
  • Index(es):
    • Date
    • Thread