Bug 116372 - gcc optimizer produces incorrect code
Summary: gcc optimizer produces incorrect code
Keywords:
Status: CLOSED DUPLICATE of bug 116366
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: gcc
Version: 9
Hardware: i686
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: David Lawrence
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2004-02-20 16:49 UTC by Need Real Name
Modified: 2007-04-18 17:03 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2006-02-21 19:01:29 UTC
Embargoed:


Attachments (Terms of Use)

Description Need Real Name 2004-02-20 16:49:08 UTC
Description of problem:
gcc optimizer option -O2 produces incorrect code

Version-Release number of selected component (if applicable):
gcc-3.2.2-5 [gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5)]

How reproducible:
Every time.

Steps to Reproduce:
1.compile and run test program with -O2 option

cat <<EOF > t.c
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main(int argc, char** argv)
{
    char *str;
    char *s;

    str = strdup("abc");
    s = str;
    printf("str is [%s], s is %c\n", str, *s);
    *s++ = toupper(*s);
    printf("str is [%s], s is %c\n", str, *s);
    free(str);
    return 0;
}
EOF
gcc -o t t.c
./t
gcc -O2 -o t t.c
./t
  
Actual results:
str is [abc], s is a
str is [Bbc], s is b

Expected results:
str is [abc], s is a
str is [Abc], s is b


Additional info:

Comment 1 Jakub Jelinek 2004-02-20 16:50:29 UTC

*** This bug has been marked as a duplicate of 116366 ***

Comment 2 Red Hat Bugzilla 2006-02-21 19:01:29 UTC
Changed to 'CLOSED' state since 'RESOLVED' has been deprecated.


Note You need to log in before you can comment on or make changes to this bug.