This is the mail archive of the gcc-bugs@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]
Other format: [Raw text]

c++/9062: gcc 3.2.0, 3.2.1 optimization bug with postincrement


>Number:         9062
>Category:       c++
>Synopsis:       gcc 3.2.0, 3.2.1 optimization bug with postincrement
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Dec 26 16:56:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     andrej.filipcic@ijs.si
>Release:        unknown-1.0
>Organization:
>Environment:
redhat 8.0
>Description:
The following code miscompiles with "g++ -O2" gcc-3.2.0, gcc-3.2.1. "-O0,1,3" gives correct results. Output of "-O2" 
is "bcdefgh" instead of "abcdefgh"

Equivalent in c only works with "-O1".
----------------------
#include <iostream>

using namespace std;

void str2lower(char *p) {
  while(*p) *p++=tolower(*p);
}

int main() {
  char str[]="Abcdefgh";
  str2lower(str);
  cout<<str<<endl;
}
>How-To-Repeat:

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


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