Re: [avr-gcc-list] OT Generic C question

2005-09-22 Thread Alan Kilian
On Thu, 2005-09-22 at 19:12 +0100, Richard Urwin wrote: There is a sequence point immediately before the assignment. So, far from being a compiler bug, this is absolutely correct behaviour. Anything else would be a bug. 1) The value of i is taken (0) 2) i is incremented (to 1)

Re: [avr-gcc-list] OT Generic C question

2005-09-20 Thread Alexandru Csete
On 9/20/05, Trampas [EMAIL PROTECTED] wrote: I was helping a friend debug some code, he is new to C, using the Keil version of GCC for ARM. Anyway I found the following: int i; i=0; i=i++; //i was still zero that i=i++ is somehow ambigous. The statement i++ means use the value of i then

Re: [avr-gcc-list] OT Generic C question

2005-09-20 Thread Wolfgang Wegner
Hi, On 20 Sep 2005 at 6:41, Trampas wrote: I was helping a friend debug some code, he is new to C, using the Keil version of GCC for ARM. Anyway I found the following: int i; i=0; i=i++; //i was still zero that I think that the right-hand side is completely evaluated before applying

RE: [avr-gcc-list] OT Generic C question

2005-09-20 Thread Trampas
understanding of the ++ operator this is indeed a bug. Sure it is bad coding but still a bug. Regards, Trampas -Original Message- From: David Brown [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 20, 2005 7:48 AM To: Trampas; avr-gcc-list@nongnu.org Subject: Re: [avr-gcc-list

Re: [avr-gcc-list] OT Generic C question

2005-09-20 Thread Marc Wetzel
Hi Trampas, Thats why you have an post-increment operator and pre-increment operator. i=++i; will give you the result, you'd expected. i++, will execute the assignment and after that the value gets inc'd ++i, will inc'd and then assign Hopefully I got it right :) /Marc Trampas wrote: I

Re: [avr-gcc-list] OT Generic C question

2005-09-20 Thread Russell Shaw
Trampas wrote: I was helping a friend debug some code, he is new to C, using the Keil version of GCC for ARM. Anyway I found the following: int i; i=0; i=i++; //i was still zero that That is i=i++ never incremented i, now I would have thought the line would be the same as: i=i; i=i+1;

Re: [avr-gcc-list] OT Generic C question

2005-09-20 Thread Colin Paul Gloster
Please pose C questions to a relevant medium, e.g. the programming questions list of the ACCU ( WWW.ACCU.org ) or one of the C newsgroups ( e.g. news:comp.lang.c or the C learners' newsgroup). On Tue, 20 Sep 2005 13:47:49 +0200, David Brown emailed: I'd agree with you that i should be 1 after

Re: [avr-gcc-list] OT Generic C question

2005-09-20 Thread varsha
ya variable i should have increamentd to 1 ... but i guess u r not using incremented value of i in your program, so compiler thinks that it is of no use and doesn't do anything with the variable...you shoud try defining i variable ...then it will not optimise the code... and will show you the

Re: [avr-gcc-list] OT Generic C question

2005-09-20 Thread Lev Vyskubov
Здравствуйте, Trampas. Вы писали 20 сентября 2005 г., 14:41:22: I was helping a friend debug some code, he is new to C, using the Keil version of GCC for ARM. Anyway I found the following: int i; i=0; i=i++; //i was still zero that That is i=i++ never incremented i, now I would have

Re: [avr-gcc-list] OT Generic C question

2005-09-20 Thread Dave Hansen
From: David Brown [EMAIL PROTECTED] - Original Message - From: Trampas [EMAIL PROTECTED] I was helping a friend debug some code, he is new to C, using the Keil version of GCC for ARM. Anyway I found the following: int i; i=0; i=i++; //i was still zero that [...] I'd agree with

Re: [avr-gcc-list] OT Generic C question

2005-09-20 Thread Nils Springob
Hi, In C the result of this expression is undefined. The C language defines that the compiler is allowed to increment the variable i before or after the assignment operation. h=i++ is valid C, h will have the old value of i, i will be incremented. i=i++ is invalid C, the value of the variable

Re: [avr-gcc-list] OT Generic C question

2005-09-20 Thread Wolfgang Wegner
On 20 Sep 2005 at 9:59, Mike Murphree wrote: Alexandru Csete said: [...] int i = 3; i = i++; gave the values 3, 4 and 7 - each of them equally correct ;-) If writing software for a safety critical system which I occasionally do, I expect my compiler not to do Bad Things(TM) and it

Re: [avr-gcc-list] OT Generic C question

2005-09-20 Thread David Kelly
On Sep 20, 2005, at 2:12 PM, Jeff Barlow wrote: Internet email is gradually degrading due to lame software and clueless users. Yes, that is exactly why I wrote. To alert the clueless. Apparently the clueless cherish their cluelessness, but that was nothing new. Yes, the messages are