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: Tree-SSA self checking infrastructure


In message <20031119190939.GR16923@atrey.karlin.mff.cuni.cz>, Jan Hubicka write
s:
 >I am still in dark here.  Can you give me some example of pointer types
 >where we don't want transitivity? What abut symmetricity?
If the inner type is a pointer and the outer type is a void *, then we
have a useless conversion.

  First realize this loses no information.  It strictly increases the
  amount of information available.

  Second realize that if the outer type was a void *, then the resulting
  pointer can only be used in very specific ways (such as parameter
  passing).  You can't do arithmetic or dereference a void * pointer.
  So the additional information you get by dropping the useless conversion
  to void * doesn't hurt either.


The opposite is not true.

Consider the case where the outer type is a function pointer and the
inner type is a void *. 

  First realize that eliminating the cast loses information.  ie, we 
  originally had a function pointer, now we have a wonderful generic
  void *.

  Second realize that the result of the original expression could be
  dereferenced.  ie, if it was a function pointer, then you can dereference
  the pointer which ultimately calls a function.  If you eliminate the
  typecast, then you're trying to dereference a void *.  Not a good idea.

  Third realize that some ABI's require in-depth knowledge about the
  called function's signature.  In fact, ia32 is an example.  The way
  parameters are passed, values returned and possibly even caller-pops
  may be dependent on the signature of the called function.  If you've
  eliminated the typecast, then you don't have access to the function's
  signature.  All hell breaks loose after that.



jeff









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