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]

[patch] for PR21985


Hello,

this bug is a stupid thinko in split_address_to_core_and_offset.
It is inconsistent in what it returns -- in all cases except when
we have ADDR_EXPR applied on memory reference whose base is not
INDIRECT_REF of the pointer, it returns address of the base object,
in the remaining case the object itself.  A consequence is that

&b - b

is believed to be 0, which causes this PR.

Bootstrapped & regtested on i686.

Zdenek

	PR tree-optimization/21985
	* fold-const.c (split_address_to_core_and_offset): Always return
	the address of the base object.

Index: fold-const.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fold-const.c,v
retrieving revision 1.593
diff -c -3 -p -r1.593 fold-const.c
*** fold-const.c	12 Jun 2005 08:03:09 -0000	1.593
--- fold-const.c	12 Jun 2005 14:53:10 -0000
*************** split_address_to_core_and_offset (tree e
*** 11802,11810 ****
        core = get_inner_reference (TREE_OPERAND (exp, 0), &bitsize, pbitpos,
  				  poffset, &mode, &unsignedp, &volatilep,
  				  false);
! 
!       if (TREE_CODE (core) == INDIRECT_REF)
! 	core = TREE_OPERAND (core, 0);
      }
    else
      {
--- 11802,11808 ----
        core = get_inner_reference (TREE_OPERAND (exp, 0), &bitsize, pbitpos,
  				  poffset, &mode, &unsignedp, &volatilep,
  				  false);
!       core = build_fold_addr_expr (core);
      }
    else
      {


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