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]

Fix to overflow problem in expand_end_case


This showed up in an Ada ACATS test.  Tested on alpha-ev56-dec-osf4.0c.

Wed Dec 12 07:37:52 2001  Olivier Hainque <hainque@act-europe.fr>

	* stmt.c (expand_end_case): Do subtraction of lower bound as trees
	to avoid overflow.

*** stmt.c	2001/12/11 23:02:48	1.237
--- stmt.c	2001/12/12 12:34:17
*************** expand_end_case (orig_index)
*** 5526,5541 ****
  	  for (n = thiscase->data.case_stmt.case_list; n; n = n->right)
  	    {
! 	      HOST_WIDE_INT i
! 		= tree_low_cst (n->low, 0) - tree_low_cst (minval, 0);
  
! 	      while (1)
! 		{
! 		  labelvec[i]
! 		    = gen_rtx_LABEL_REF (Pmode, label_rtx (n->code_label));
! 		  if (i + tree_low_cst (minval, 0)
! 		      == tree_low_cst (n->high, 0))
! 		    break;
! 		  i++;
! 		}
  	    }
  
--- 5526,5543 ----
  	  for (n = thiscase->data.case_stmt.case_list; n; n = n->right)
  	    {
! 	      /* Compute the low and high bounds relative to the minimum
! 		 value since that should fit in a HOST_WIDE_INT while the
! 		 actual values may not.  */
! 	      HOST_WIDE_INT i_low
! 		= tree_low_cst (fold (build (MINUS_EXPR, index_type, 
!                                              n->low, minval)), 1);
! 	      HOST_WIDE_INT i_high
! 		= tree_low_cst (fold (build (MINUS_EXPR, index_type, 
!                                              n->high, minval)), 1);
! 	      HOST_WIDE_INT i;
  
! 	      for (i = i_low; i <= i_high; i ++)
! 		labelvec[i]
! 		  = gen_rtx_LABEL_REF (Pmode, label_rtx (n->code_label));
  	    }
  


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