increasing var twice in a statement

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi!

Can anybody tell me what output the following program snippet should
produce according to C standard:

int main(void) {
	int a;
	int b;
	b = 3;
	a = ++b + ++b;
	printf("%d\n",a);
	return 0;
}

I would have expected 9, but gcc 4.1.2 produced a binary that wrote 10.

Willi

Please CC: me in replys, I'm not on the list.

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux