This is the mail archive of the gcc@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]

Re: G++ internal pointer cast NULL check inefficiency


	I think that one can assert nonnull unconditionally for the case I
found.  One of the tests that guards the conversion is:

          /* If EXPR is NULL, then we don't need to do any arithmetic
             to convert it:

               [conv.ptr]

               The null pointer value is converted to the null pointer
               value of the destination type.  */
          && !integer_zerop (expr))

so it seems the compiler already has ensured the originating pointer
expression is non-null and therefore no need to re-test that assertion at
runtime. 

	* cvt.c (cp_convert_to_pointer): Do not re-test EXPR for NULL when
	building vbase path.

Index: cvt.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/cvt.c,v
retrieving revision 1.50
diff -c -p -r1.50 cvt.c
*** cvt.c	1998/12/22 12:18:11	1.50
--- cvt.c	1999/01/07 23:01:20
*************** cp_convert_to_pointer (type, expr)
*** 173,179 ****
  		  else
  		    get_base_distance (TREE_TYPE (intype), TREE_TYPE (type),
  				       0, &path);
! 		  return build_vbase_path (code, type, expr, path, 0);
  		}
  	    }
  	}
--- 173,179 ----
  		  else
  		    get_base_distance (TREE_TYPE (intype), TREE_TYPE (type),
  				       0, &path);
! 		  return build_vbase_path (code, type, expr, path, 1);
  		}
  	    }
  	}


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