c/6917: optimization problem in gcc 3.1

valera.veryazov@teokem.lu.se valera.veryazov@teokem.lu.se
Mon Jun 3 05:26:00 GMT 2002


>Number:         6917
>Category:       c
>Synopsis:       optimization problem in gcc 3.1
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jun 03 05:26:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Valera Veryazov
>Release:        gcc 3.1
>Organization:
>Environment:
Linux Mandrake 8.2
>Description:
the code is working well under gcc 3.0.4,
but give different results under gcc 3.1
with -O2 and -O1 flags.

#include <stdio.h>
void main (void)
{
   char     magic[8] = { 0x7f , 'A' , 'B' , 'C' , 'D' , 'E' , 'F' , 0x7f };
   int     *MAGIC;
   MAGIC = (int *)(&magic[0]);
   printf (">> %d \n",*MAGIC);
   return;
}
>How-To-Repeat:
compile the code with -O2 and -O1 options for gcc 3.1
>Fix:

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

I2luY2x1ZGUgPHN0ZGlvLmg+CnZvaWQgbWFpbiAodm9pZCkKewogICBjaGFyICAgICBtYWdpY1s4
XSA9IHsgMHg3ZiAsICdBJyAsICdCJyAsICdDJyAsICdEJyAsICdFJyAsICdGJyAsIDB4N2YgfTsK
ICAgaW50ICAgICAqTUFHSUM7CiAgIE1BR0lDID0gKGludCAqKSgmbWFnaWNbMF0pOwogICBwcmlu
dGYgKCI+PiAlZCBcbiIsKk1BR0lDKTsKICAgcmV0dXJuOwp9Cg==



More information about the Gcc-bugs mailing list