Bug 11855 - aliasing problem
Summary: aliasing problem
Status: RESOLVED DUPLICATE of bug 21920
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 3.2.2
: P2 normal
Target Milestone: 3.4.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-08-08 14:12 UTC by Fabien Douze
Modified: 2005-07-23 22:49 UTC (History)
1 user (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Fabien Douze 2003-08-08 14:12:23 UTC
I have the following code

typedef struct _LSPESn  
{ 
    struct _LSPESn *esnext;          /* next ES neighbour in LSP chain */ 
     
    X               esdefm;          /* ES neighbour default metric    */ 
    X               esdlym;          /* ES neighbour delay metric      */ 
    X               esexpm;          /* ES neighbour expense metric    */ 
    X               eserrm;          /* ES neighbour error metric      */ 
    X               esid[LGSYSID];   /* ES neighbour system ID         */ 
} LSPESnT, *LSPESnTp; 

typedef struct STC
{
  struct STC *stnext ;
}
ST, *STp;



   LSPESnTp es2, esn; 

   for ( esn = ent->lspesn ; 0!=esn ; esn = es2 )
   {
      es2 = esn->esnext;
      (((STp)(  (STp)esn  ))->stnext)  = ( &(((SATenTp)( E2Ispp ))->sat_i2i. fr
eeLspESn )  )->prp_first; 
      ( & (((SATenTp)( E2Ispp ))->sat_i2i.reeLspESn )  )->prp_first = ((STp)( 
(STp)esn )); ;
   }

It causes an infinit loop when compiling with -O2 option. 
Apperently, gcc considere esn->esnext and (((STp)(  (STp)esn  ))->stnext) as
two different memory area and skip es2 in the generated library.

Isn't it a gcc bug?
It seems to be the same case than in bug 9902. But I do not see
which aliasing rules is not respected.

Thanks,
Fabien
Comment 1 Falk Hueffner 2003-08-08 14:41:57 UTC
There is only one:

"An object shall have its stored value accessed only by an lvalue
expression that has one of the following types:

-- a type compatible with the effective type of the object,
-- a qualified version of a type compatible with the effective type of the object,
-- a type that is the signed or unsigned type corresponding to the
   effective type of the object,
-- a type that is the signed or unsigned type corresponding to a
   qualified version of the effective type of the object,
-- an aggregate or union type that includes one of the aforementioned
   types among its members (including, recursively, a member of a
   subaggregate or contained union), or
-- a character type."

and this is exactly the one you are violating, since you're accessing struct
_LSPESn as STC.
Comment 2 Andrew Pinski 2005-06-05 08:27:20 UTC
Reopening to ...
Comment 3 Andrew Pinski 2005-06-05 08:27:36 UTC
Mark as a dup of bug 21920.

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