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]

optimization/5800: gcc -O0 produces wrong code



>Number:         5800
>Category:       optimization
>Synopsis:       gcc -O0 produces wrong code
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Fri Mar 01 03:46:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     gcc
>Release:        3.0.4
>Organization:
>Environment:
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ../gcc-3.0.4/configure
>Description:
gcc with optimization -O0 produces wrong code for the file comp.c:

#include <stdlib.h>

int main()
{
  int a[] = { 1, 1};
  printf("%i %i\n",a[0],a[1]);

  a[1] = a[0] && a[1];
  printf("%i %i\n",a[0],a[1]);

  return(1);
}

Compiled with: 
gcc -O0 comp.c

Program output:
1 1
1 0

Which is definitely wrong ("1 1" expected)
>How-To-Repeat:
Compile attached file with gcc -O0 comp.c and see results
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="comp.c"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="comp.c"

CiNpbmNsdWRlIDxzdGRsaWIuaD4KCmludCBtYWluKCkKewogIGludCBhW10gPSB7IDEsIDF9Owog
IHByaW50ZigiJWkgJWlcbiIsYVswXSxhWzFdKTsKCiAgYVsxXSA9IGFbMF0gJiYgYVsxXTsKICBw
cmludGYoIiVpICVpXG4iLGFbMF0sYVsxXSk7CgogIHJldHVybigxKTsKfQo=


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