[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] OT Generic C question
From: |
Colin Paul Gloster |
Subject: |
Re: [avr-gcc-list] OT Generic C question |
Date: |
Tue, 20 Sep 2005 13:20:56 +0100 |
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 "i = i++", despite the sillyness
of the statement. [..] it's quite likely that it remained at 0
due to legitimate compiler optomisations."
I am not convinced that i should be 1 after i = i++ and I am not convinced
that optimization is relevant.
On Tue, 20 Sep 2005 13:35:13 +0200 Bernard Fouché emailed:
"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;
>
>
>
>
i++ means 'get i value, afterwards increment it'. So
i=i++ will increment i, but after having read it to assign its value to
itself :-)
[..]"
I think that the rules of the value of the expression i++ might be different
in C and Java, but in both languages, i=i++; means to assign the value of
the expression i++ to i and in at least one of those languages, the value
of the expression i++ is not equivalent to the sideeffect which i++ has on
i. Please check for yourself what it is defined to be in C.
- Re: [avr-gcc-list] Initilizing complex const arrays : syntax ?, (continued)
- Re: [avr-gcc-list] Initilizing complex const arrays : syntax ?, Vincent Trouilliez, 2005/09/18
- 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 <=
- Re: [avr-gcc-list] OT Generic C question, David Brown, 2005/09/20
- 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