This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: G++ internal pointer cast NULL check inefficiency
- To: mrs at wrs dot com (Mike Stump)
- Subject: Re: G++ internal pointer cast NULL check inefficiency
- From: David Edelsohn <dje at watson dot ibm dot com>
- Date: Thu, 07 Jan 1999 18:11:00 -0500
- Cc: egcs at egcs dot cygnus dot com, egcs-patches at cygnus dot com
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);
}
}
}