neat bug in alias analysis

Mark Mitchell mark@codesourcery.com
Tue Aug 31 22:41:00 GMT 1999


>>>>> "Mike" == Mike Stump <mrs@wrs.com> writes:

    >> I agree with you, then, that the comment I inserted in your
    >> code should be removed, and replaced instead with a brief
    >> summary of the above discussion.  Do you concur?

    Mike> Yes.

I checked in the attached patch.

--
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com

Fri Aug 20 15:02:10 1999  Mark Mitchell  <mark@codesourcery.com>

	* c-common.c (c_get_alias_set): Update comment.

Index: c-common.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/c-common.c,v
retrieving revision 1.64
diff -c -p -r1.64 c-common.c
*** c-common.c	1999/08/19 21:39:04	1.64
--- c-common.c	1999/08/20 21:56:06
*************** c_get_alias_set (t)
*** 3411,3421 ****
  	 `I *' are different types.  So, we have to pick a canonical
  	 representative.  We do this below.
  	 
! 	 Note that this approach is actually more conservative that it
! 	 needs to be.  In particular, `const int *' and `int *' should
! 	 be in different alias sets, but this approach puts them in
! 	 the same alias set.  */
  
        t = TYPE_MAIN_VARIANT (TREE_TYPE (type));
        t = ((TREE_CODE (type) == POINTER_TYPE)
  	   ? build_pointer_type (t) : build_reference_type (t));
--- 3411,3434 ----
  	 `I *' are different types.  So, we have to pick a canonical
  	 representative.  We do this below.
  	 
! 	 Technically, this approach is actually more conservative that
! 	 it needs to be.  In particular, `const int *' and `int *'
! 	 chould be in different alias sets, according to the C and C++
! 	 standard, since their types are not the same, and so,
! 	 technically, an `int **' and `const int **' cannot point at
! 	 the same thing.
  
+          But, the standard is wrong.  In particular, this code is
+ 	 legal C++:
+ 
+             int *ip;
+             int **ipp = &ip;
+             const int* const* cipp = &ip;
+ 
+          And, it doesn't make sense for that to be legal unless you
+ 	 can dereference IPP and CIPP.  So, we ignore cv-qualifiers on
+ 	 the pointed-to types.  This issue has been reported to the
+ 	 C++ committee.  */
        t = TYPE_MAIN_VARIANT (TREE_TYPE (type));
        t = ((TREE_CODE (type) == POINTER_TYPE)
  	   ? build_pointer_type (t) : build_reference_type (t));



More information about the Gcc-patches mailing list