• 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: Booleans not being set
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Booleans not being set


  • Subject: Re: Booleans not being set
  • From: Andreas Grosam <email@hidden>
  • Date: Mon, 9 Feb 2009 12:51:41 +0100


On Feb 9, 2009, at 1:11 AM, Steve Checkoway wrote:


On Feb 7, 2009, at 1:43 AM, Erg Consultant wrote:

I have a simple C routine which looks roughly like this:

I'd like to know why this is happening as a routine returning true even when I set the return value to false is not the way code nor a compiler should behave.


Have you tried changing it to

Boolean IsOnline( char *host, Boolean checkConnection )
{
       Boolean result = false;
       return result;
}

and checking if it still returns true? While compiler bugs are certainly possible, it seems pretty unlikely. Note that in addition to project and target settings, individual files can have compiler flags. It'd be worth looking at the actual build commands to ensure that no optimization flags are being passed to the compiler.


the statement

return result;

will always set the target variable outside the function - no matter how you corrupted the stack with invalid statements within the function, and no matter of the alignment of the target variable. At least in debug mode, where commands are not reordered.

I can imagine, that a different declaration of Boolean in the two translation units may cause this behavior. I would check also, if Boolean conflicts with _BOOL and bool respectively.

One other reason it might be, is a possible unnoticed bug (stack will be corrupted from commands within the function), a different alignment and a different assembly on machine level in the PCC architecture - so that the bug becomes apparent only there.

Hint:
Look at the "char* host" parameter: it's content may be changed. The compiler has no means to check for xcvalid bounds. Better you use 
const char* host

I bet it is 99.9999% a bug in the code.   ;)


Andreas

 _______________________________________________
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

References: 
 >Booleans not being set (From: Erg Consultant <email@hidden>)
 >Re: Booleans not being set (From: Steve Checkoway <email@hidden>)

  • Prev by Date: Re: Help on Stack trace
  • Next by Date: Re: Application Verification Failed Problem
  • Previous by thread: Re: Booleans not being set
  • Next by thread: Re: Booleans not being set
  • Index(es):
    • Date
    • Thread