This is the mail archive of the gcc-prs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

c/457: Invalid code generation for postfix ++ operator



>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;
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]