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][4.1/4.2] Fix PR27409, ICE in get_constraint_for_component_ref


This fixes the fact that we don't handle access to embedded zero sized
structs that happen to land in some padding region.

Bootstrapped and tested on x86_64-unknown-linux-gnu for trunk and
$archs_we_ship for 4.1 (adjust s/bitmaxsize/bitsize/ in the patch).

Ok for mainline and 4.1?

Thanks,
Richard.

:ADDPATCH aliasing:

2006-05-03  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/27409
	* tree-ssa-structalias.c (get_constraint_for_component_ref):
	Do not try to find zero-sized subvars.

	* gcc.dg/torture/pr27409.c: New testcase.

Index: tree-ssa-structalias.c
===================================================================
*** tree-ssa-structalias.c	(revision 113493)
--- tree-ssa-structalias.c	(working copy)
*************** get_constraint_for_component_ref (tree t
*** 2378,2384 ****
  	 ignore this constraint. When we handle pointer subtraction,
  	 we may have to do something cute here.  */
        
!       if (result->offset < get_varinfo (result->var)->fullsize)
  	{
  	  /* It's also not true that the constraint will actually start at the
  	     right offset, it may start in some padding.  We only care about
--- 2378,2385 ----
  	 ignore this constraint. When we handle pointer subtraction,
  	 we may have to do something cute here.  */
        
!       if (result->offset < get_varinfo (result->var)->fullsize
! 	  && bitmaxsize != 0)
  	{
  	  /* It's also not true that the constraint will actually start at the
  	     right offset, it may start in some padding.  We only care about
*************** get_constraint_for_component_ref (tree t
*** 2400,2405 ****
--- 2401,2412 ----
  	     embedded in a struct resulting in accessing *only* padding.  */
  	  gcc_assert (curr || ref_contains_array_ref (orig_t));
  	}
+       else if (bitmaxsize == 0)
+ 	{
+ 	  if (dump_file && (dump_flags & TDF_DETAILS))
+ 	    fprintf (dump_file, "Access to zero-sized part of variable,"
+ 		     "ignoring\n");
+ 	}
        else
  	if (dump_file && (dump_flags & TDF_DETAILS))
  	  fprintf (dump_file, "Access to past the end of variable, ignoring\n");
Index: testsuite/gcc.dg/torture/pr27409.c
===================================================================
*** testsuite/gcc.dg/torture/pr27409.c	(revision 0)
--- testsuite/gcc.dg/torture/pr27409.c	(revision 0)
***************
*** 0 ****
--- 1,17 ----
+ /* { dg-do compile } */
+ 
+ typedef struct {
+         struct { } z;
+ } thang_t;
+ 
+ struct {
+         short           e;
+         thang_t         f;
+         int g;
+ } my_struct;
+ 
+ void function(int blaz)
+ {
+   thang_t *fp = &my_struct.f;
+   foo(fp);
+ }


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