This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
cp/cvt: don't assume pointer sizes
- From: DJ Delorie <dj at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 21 Jul 2011 17:50:47 -0400
- Subject: cp/cvt: don't assume pointer sizes
Some targets (m32c, tpf, mips) have more than one pointer size. It is
not correct to assume that a pointer is POINTER_SIZE.
Index: gcc/cp/cvt.c
===================================================================
--- gcc/cp/cvt.c (revision 176554)
+++ gcc/cp/cvt.c (working copy)
@@ -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)));
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;
}