Comments
Patch
===================================================================
@@ -217,15 +217,16 @@ cp_convert_to_pointer (tree type, tree e
error ("invalid conversion from %qT to %qT", intype, type);
return error_mark_node;
}
if (INTEGRAL_CODE_P (form))
{
- if (TYPE_PRECISION (intype) == POINTER_SIZE)
+ int this_pointer_size = TYPE_PRECISION (type);
+ if (TYPE_PRECISION (intype) == this_pointer_size)
return build1 (CONVERT_EXPR, type, expr);
- expr = cp_convert (c_common_type_for_size (POINTER_SIZE, 0), expr);
+ expr = cp_convert (c_common_type_for_size (this_pointer_size, 0), expr);
/* Modes may be different but sizes should be the same. There
is supposed to be some integral type that is the same width
as a pointer. */
gcc_assert (GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (expr)))
== GET_MODE_SIZE (TYPE_MODE (type)));
Some targets (m32c, tpf, mips) have more than one pointer size. It is not correct to assume that a pointer is POINTER_SIZE. TPF tescase (default pointer and int are 64 bits): typedef void * __attribute__ ((mode (SI))) __ptr32_t; unsigned int foo; __ptr32_t foo_addr; int bar( ) { foo_addr = (__ptr32_t)foo; return 0; }