This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
c/457: Invalid code generation for postfix ++ operator
- To: gcc-gnats at gcc dot gnu dot org
- Subject: c/457: Invalid code generation for postfix ++ operator
- From: bland at japan dot com
- Date: 10 Aug 2000 02:01:41 -0000
- Cc: mikhail at gol dot com
- Reply-To: bland at japan dot com
- Resent-Cc: gcc-prs at gcc dot gnu dot org, gcc-bugs at gcc dot gnu dot org, mikhail at gol dot com
- Resent-Reply-To: gcc-gnats@gcc.gnu.org, bland@japan.com
>Number: 457
>Category: c
>Synopsis: Invalid code generation for postfix ++ operator
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: wrong-code
>Submitter-Id: net
>Arrival-Date: Wed Aug 09 19:06:00 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator: bland@japan.com
>Release: gcc 2.95.2
>Organization:
>Environment:
SunOS leo 5.6 Generic_105181-19 sun4u sparc SUNW,Ultra-5_10
>Description:
The attached sample prints 1, 2, 2 instead of 1, 1, 1.
Btw, this behaviour is different from x86 codegen.
>How-To-Repeat:
compile string: gcc -O0 -Wall bug.cxx
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="bug.cxx"
Content-Disposition: inline; filename="bug.cxx"
#include <iostream>
using namespace std;
void print (const char& c)
{
cerr << c << endl;
}
void uprint (const unsigned char& c)
{
cerr << c << endl;
}
void sprint (const signed char& c)
{
cerr << c << endl;
}
int
main (void)
{
const char *s1, *s2, *s3;
s1 = s2 = s3 = "123";
print (*s1++);
uprint (*s2++);
sprint (*s3++);
return 0;
}