This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/32133] New: Post-increment gained unintuitive behaviour
- From: "j dot witteveen at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 28 May 2007 22:44:58 -0000
- Subject: [Bug c++/32133] New: Post-increment gained unintuitive behaviour
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
I noticed a change in the implementation of the post-increment (i++) operator
in gcc 4.0.1 (Apple build 5367).
The behaviour can be seen with the following code:
---
i += i++;
---
In older versions (< 4) of g++ the 'original' variable is returned by ++,
meaning that the statement given has the effect of doubling the value of i. The
new version of ++ seems to return the 'copy', leading to i just being
incremented by one in the end.
The situation I think of as the most intuitive would be something like this:
---
(i += i)++
---
I realise though that operator precedence prohibits such behaviour.
The following two lines demonstrate, however, why I think the old behaviour is
desired over the new one:
---
(i++ < i); //Used to be true, now false
(i > i++); //Idem
---
Modern versions even make this true:
---
i++ == i++
---
Which, I think, is not what one wants.
Regards,
- Jouke
--
Summary: Post-increment gained unintuitive behaviour
Product: gcc
Version: 4.0.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: j dot witteveen at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32133