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

Re: Your sizetype changes ...


    The underlying reason is that the C++ front-end contains this code, in
    ocp_convert:

      if (same_type_p (type, TREE_TYPE (e)))
	return e;

    which says that if `e' is of the same type as `type', then you don't
    need to do any conversion; just return `e'.

    Now that breaks if TYPE_IS_SIZETYPE holds for `type', but not for
    `TREE_TYPE (e)'.

    The notion of "same type" is a language-specific one, and in C++, like
    C, `unsigned int' and `size_t' are often the same type.  

Didn't I add code to the size comparison code to handle that?  Or did I
just do it in one direction and not teh other?

    *Anything* that is legal to do with a size_t is also legal to do with
    an unsigned int, and vice versa.  So, this comment:

No.  The case is (x * 40) / 20.  If x is a normal unsigned type, you
can't convert this to x*2 because the x*40 might have overflowed.  But
if it's an actual sizetype, you can.

    In any case, there's no reason to change the behavior of the C++
    front-end.  For instance, adding a NOP_EXPR to convert to a type with
    TYPE_IS_SIZETYPE set would be silly; it's semantically meaningless to
    the front-end, and the back-end can't make use of the information for
    any optimization since, say, a cast to `size_t' doesn't make for any
    different properties of the underlying expression.

Right, I wasn't proposing doing it that way, just considering the
two types as equivalent.

    2000-02-29  Mark Mitchell  <mark@codesourcery.com>

	* fold-const.c (size_binop): Don't asert inputs are the same
	and have TYPE_IS_SIZETYPE set.
	(size_diffop): Likewise.

I hope this is *very* temporary because this disables *critically important*
internal check with sizes.  Indeed you were the person who was most concerned
about misuse of sizetypes and were the motivation for that change.

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