[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] OT Generic C question
From: |
David Brown |
Subject: |
Re: [avr-gcc-list] OT Generic C question |
Date: |
Tue, 20 Sep 2005 13:47:49 +0200 |
----- Original Message -----
From: "Trampas" <address@hidden>
> 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;
>
> So you guys are the smartest people I know when it comes to C so I thought
I
> would ask you guys if this is a compiler bug or is my understanding of C
> just been shaken.
>
> Regards,
> Trampas
>
>
I'd agree with you that i should be 1 after "i = i++", despite the sillyness
of the statement. However, how did you check that i was still 0? If the
compiler had no reason to actually carry out the incrementation, and you
used a debugger to view "i", then it's quite likely that it remained at 0
due to legitimate compiler optomisations.
- Re: [avr-gcc-list] Initilizing complex const arrays : syntax ?, (continued)
- Re: [avr-gcc-list] Initilizing complex const arrays : syntax ?, David Kelly, 2005/09/18
- Re: [avr-gcc-list] Initilizing complex const arrays : syntax ?, Vincent Trouilliez, 2005/09/19
- Re: [avr-gcc-list] Initilizing complex const arrays : syntax ?, David Kelly, 2005/09/19
- Re: [avr-gcc-list] Initilizing complex const arrays : syntax ?, Dave Hansen, 2005/09/19
- Re: [avr-gcc-list] Initilizing complex const arrays : syntax ?, David Brown, 2005/09/19
- Re: [avr-gcc-list] Initilizing complex const arrays : syntax ?, Richard Urwin, 2005/09/19
- Re: [avr-gcc-list] Initilizing complex const arrays : syntax ?, David Brown, 2005/09/20
- [avr-gcc-list] OT Generic C question, Trampas, 2005/09/20
- Re: [avr-gcc-list] OT Generic C question, Bernard Fouché, 2005/09/20
- Re: [avr-gcc-list] OT Generic C question, Colin Paul Gloster, 2005/09/20
- Re: [avr-gcc-list] OT Generic C question,
David Brown <=
- RE: [avr-gcc-list] OT Generic C question, Trampas, 2005/09/20
- Re: [avr-gcc-list] OT Generic C question, Dave Hansen, 2005/09/20
- Re: [avr-gcc-list] OT Generic C question, Richard Urwin, 2005/09/22
- Re: [avr-gcc-list] OT Generic C question, Alan Kilian, 2005/09/22
- Re: [avr-gcc-list] OT Generic C question, Dave Hansen, 2005/09/22
- Re: [avr-gcc-list] OT Generic C question, Richard Urwin, 2005/09/22
- Re: [avr-gcc-list] OT Generic C question, Dave Hansen, 2005/09/22
- Re: [avr-gcc-list] OT Generic C question, Alexandru Csete, 2005/09/20
- Re: [avr-gcc-list] OT Generic C question, Wolfgang Wegner, 2005/09/20
- Re: [avr-gcc-list] OT Generic C question, Julius Luukko, 2005/09/20