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)
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
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
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
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
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;
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
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
Здравствуйте, 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
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
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
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
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
13 matches
Mail list logo