Bug 6917 - optimization problem in gcc 3.1
Summary: optimization problem in gcc 3.1
Status: RESOLVED DUPLICATE of bug 21920
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 3.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-06-03 05:26 UTC by valera.veryazov
Modified: 2005-11-10 03:52 UTC (History)
50 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
a.c (158 bytes, application/octet-stream)
2003-05-21 15:16 UTC, valera.veryazov
Details

Note You need to log in before you can comment on or make changes to this bug.
Description valera.veryazov 2002-06-03 05:26:01 UTC
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;
}

Release:
gcc 3.1

Environment:
Linux Mandrake 8.2

How-To-Repeat:
compile the code with -O2 and -O1 options for gcc 3.1
Comment 1 Volker Reichelt 2002-11-22 08:17:30 UTC
State-Changed-From-To: open->closed
State-Changed-Why: Not a bug.
    
    You are not obeying the aliasing rules and thus invoking undefined behaviour.
    If you want the compiler not to perform optimizations based on alias-analysis,
    you can specify "-fno-strict-aliasing".
Comment 2 Andrew Pinski 2005-11-10 03:51:44 UTC
Reopening to ...
Comment 3 Andrew Pinski 2005-11-10 03:52:00 UTC
Mark as a dup of bug 21920.

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