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]

varasm patch: initializer constants


hi guys.

compile/20010327-1.c is segfaulting on mips64 when longs are 32bits but
pointers are 64bits:

    extern void _text;
    static unsigned long x = (unsigned long) &_text - 0x10000000L - 1;
    
gcc is trying to generate rtl to do the truncation and causing a
segfault (because it can't generate code-- it thought it was a
constant).

this patch catches the case in initializer_constant_valid_p() and makes
sure we're talking about a constant.

ok to install?
    
-- 
Aldy Hernandez					E-mail: aldyh@redhat.com
Professional Gypsy
Red Hat, Inc.

        * varasm.c (initializer_constant_valid_p): Make sure conversions
	between integer types are of the same size.

Index: varasm.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gcc/varasm.c,v
retrieving revision 1.269
diff -c -p -r1.269 varasm.c
*** varasm.c	2001/08/06 15:20:55	1.269
--- varasm.c	2001/09/07 14:23:07
*************** initializer_constant_valid_p (value, end
*** 3974,3982 ****
  	return initializer_constant_valid_p (TREE_OPERAND (value, 0),
endtype);
  
        /* Allow conversions between other integer types only if
! 	 explicit value.  */
        if (INTEGRAL_TYPE_P (TREE_TYPE (value))
! 	  && INTEGRAL_TYPE_P (TREE_TYPE (TREE_OPERAND (value, 0))))
  	{
  	  tree inner = initializer_constant_valid_p (TREE_OPERAND (value, 0),
  						     endtype);
--- 3974,3983 ----
  	return initializer_constant_valid_p (TREE_OPERAND (value, 0),
endtype);
  
        /* Allow conversions between other integer types only if
! 	 explicit value and there is no size change.  */
        if (INTEGRAL_TYPE_P (TREE_TYPE (value))
! 	  && INTEGRAL_TYPE_P (TREE_TYPE (TREE_OPERAND (value, 0)))
! 	  && TYPE_PRECISION (TREE_TYPE (value)) == TYPE_PRECISION (TREE_TYPE
(TREE_OPERAND (value, 0))))
  	{
  	  tree inner = initializer_constant_valid_p (TREE_OPERAND (value, 0),
  						     endtype);


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