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 ;
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.
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.
Reopening to ...
Mark as a dup of bug 21920.
*** This bug has been marked as a duplicate of 21920 ***