% cat a.c
int main(void)
{
int i;
for(i = 0; i < 10; ++i)
{
puts("GRUNNUR");
}
return 0;
}
% cat b.c
int main(void)
{
int i;
for(i = 0; i < 10; i++)
{
puts("GRUNNUR");
}
return 0;
}
% gcc -S a.c; gcc -S b.c
% diff a.s b.s
1c1
< .file "a.c"
--- .file "b.c"
% gcc --version
gcc (Gentoo 4.3.3-r2 p1.1, pie-10.1.5) 4.3.3
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
They are not the same, even when used as an expression-instruction:
++i; increments the value of i first and then puts it on the stack, to be immediately after cleared out (since the value isn't used)
i++; first puts 'i' on the stack, duplicates it, increments one 'i' and puts it back to 'i', leaving the unchanged value on the stack to be used if needed (cleared out after, as it isn't used)
to summarize, 'i++' uses one duplicate more than '++i'
Name:
Anonymous2009-05-29 16:55
>>20
wrong. you're a fucking moron that doesn't understand shit.
You're talking about the observations in a specific implementaiton under specific architecture models with a shitty compiler anyway. You assume a stack too -- C doesn't even need a stack. go fuck yourself, fucking C n00bs I hate them.
Name:
Anonymous2009-05-29 16:58
++i Considered Trolling
Name:
Anonymous2009-05-29 17:06
>>22 ++i considered the default way of incrementing a variable. K&R uses it throughout.
>>21
Is it really necessary to be so nasty?
I just don't think we should be the type of community to belittle others like that. This isn't /b/, this is /prog/. Show some manners, please :-)