This is the mail archive of the gcc@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]

Re: module level flags


Zack Weinberg wrote:

> I'm afraid the compiler is working as designed.
> 
> >          YYSTYPE  def,
> >          YYSTYPE  list )
> >  {
> > +    tDefEntry*  ret   = (tDefEntry*)list;
> >      tDefEntry*  pDef  = (tDefEntry*)def;
> > -    tDefEntry*  pScn  = (tDefEntry*)list;
> > -    tDefEntry** ppT   = (tDefEntry**)&list;
> > +    tDefEntry*  pScn  = ret;
> > +    tDefEntry** ppT   = &ret;
> 
> In the original code, the type-based aliasing rules permit the
> compiler to assume that assignment to ppT does not modify list
> EVEN THOUGH IT IS OBVIOUS TO A HUMAN THAT IT DOES.
> 
> Your fix is the right way to correct your code.  By immediately
> assigning list to a temporary with its true type, you show the
> compiler what's really going on.

That is completely goofy.  Is that really the intent of the
official standard, or GCC's interpretation?  This method of
dealing with untyped buckets should be entirely equivalent
to retyped void* pointers -- viz., disabling aliasing optimizations.
Any other interpretation is too confusing to be able to remember.
In other words, wrong.

Bruce Korb <first initial + last name at gnu dot org>
AG URL: http://autogen.sourceforge.net


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