This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/20181] Increment/decrement
- From: "d_picco at hotmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 23 Feb 2005 20:24:27 -0000
- Subject: [Bug c/20181] Increment/decrement
- References: <20050223202254.20181.d_picco@hotmail.com>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From d_picco at hotmail dot com 2005-02-23 20:24 -------
(In reply to comment #0)
> Consider these situations:
>
> int a = 0;
> int b = a++ + a++;
> int c = (a++) + (a++);
> int d = a++ + (a++);
> int e = (a++) + a++;
>
> b == c == d == e == 0. I understand based on a previous bug about sequence
> points in C++ but I think a common-sense approach takes precident here. If 'a'
> were a user-defined class with the operator++ (postfix), how could the user
> mimic such behaviour, namely b == c == d == e == 0? In fact they couldn't. The
> proper solution is then to have b == c == d == e == 1.
I should have clarified this more:
Consider these situations:
Case 1
======
int a = 0;
int b = a++ + a++
Case 2
======
int a = 0;
int c = (a++) + a++;
Case 3
======
... etc
Otherwise b != c != d != e if the situations were read sequentially
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20181