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]
Other format: [Raw text]

Complete fix to pointer size assumption in convert


Hello,

This is a completion for an issue first raised at

   http://gcc.gnu.org/ml/gcc-patches/2009-07/msg01413.html,

an unwarranted assumption in convert that every pointer is
POINTER_SIZE wide, typically not true for targets which define
TARGET_VALID_POINTER_MODE (e.g. vms).

The initial change was for "convert_to_pointer", for a case like

     typedef char* ptr32 __attribute__ (( mode (SI) ));

     void to_ptr32 (int x)
     {
       ptr32 ptr = (ptr32) x;
     }

After a followup exchange at

  http://gcc.gnu.org/ml/gcc-patches/2009-08/msg00901.html

This patch is the counterpart for convert_to_integer, to handle the
symetric case:

     void to_int (ptr32 ptr)
     {
       int x = (int) ptr;
     }

For s390 or 64bit vms targets (alpha or itanium), the problem gets
visible as the insertion of an extraneous intermediate conversion to
(long int), and an ICE someplace downstream with enable-checks=all.

Thanks in advance,

Olivier

2009-08-21  Olivier Hainque  <hainque@adacore.com>

	* convert.c (convert_to_integer): Don't assume an input
	pointer is POINTER_SIZE wide.  Fetch from the type instead.

Attachment: intptr.dif
Description: Text document


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