• 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: For loop shenanigans
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: For loop shenanigans


  • Subject: Re: For loop shenanigans
  • From: Jose Commins <email@hidden>
  • Date: Sat, 6 Dec 2003 00:06:25 +0000

On 5 Dec 2003, at 21:51, Richard Clark wrote:

Run this code:

#include <stdio.h>

int main (int argc, const char * argv[]) {
     int i;
     for (i = 0; i < 9; i += 3) {
         if (i > 0) printf(", ");
         printf("%d", i);
     }
     return 0;
}

and note that it prints "0, 3, 6" as it should. You'll need to look
elsewhere in your code for the problem (and note that a compiler bug is
a bug of last resort; in 20 years of programming I've found only one
honest compiler bug and that was an odd cross-TOC calling bug when
Apple's PowerPC systems were still in Alpha testing and they were
extensively modifying the compiler.)

  ...Richard


I have found several (reported) compiler bugs throughout the years - this is a strange one. I do test first and foremost if it is my code which is causing the problem. Your code (and the original) works after I changed some settings as I was so frustrated by the end of it I reinitialised the whole project. I am finding out exactly what settings were causing the problem.
I found even tracing through the debugger that 'i' was starting at 3. If I do a new project in Xcode it works fine. Grr!




On Dec 5, 2003, at 12:41 AM, Matt Gough wrote:

>>>   for(i = 0; i < 9; i += 3);
>>>   {
>>>       ... blah...
>>>   }
>>>
>>>   i is equal to 3 on entry to the loop, which it shouldn't be.
>>>
>>>   Bug in Xcode, or GCC?
>>
>> Short between seat and keyboard? Note semicolon after the 'for'
>> statement
>

Oopsie :o) Thanks for spotting the typo.

> Ignoring the fact that the code is probably not as intended, surely i
> should
> be 9 by the time it gets to ...blah... instead of 3.

It's just an example to show the intended error - the actual code had a few more bits to it.


Regards,
		Jose.

--
Death, taxes and Microsoft. If you put it that way, the first two don't seem so bad.
_______________________________________________
xcode-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/xcode-users
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: terminal apps
  • Next by Date: Re: For loop shenanigans (update)
  • Previous by thread: Re: terminal apps
  • Next by thread: Re: For loop shenanigans (update)
  • Index(es):
    • Date
    • Thread