G++ internal pointer cast NULL check inefficiency

David Edelsohn dje@watson.ibm.com
Sun Jan 31 23:58:00 GMT 1999


>>>>> Mike Stump writes:

>> The compiler apparently is trying to preserve a NULL value and protect the
>> first dereference, but notice that immediately following is another
>> dereference which will fail.

>> Is there a reason that G++ cannot produce more efficient code in
>> this case?

Mike> None.  Should be fairly easy for someone to fix.  grep nonnull in
Mike> cp/*.c to get started.

	I do not have much knowledge of the G++ front-end. Looking over
the code, it appears that class.c:build_vbase_path() should be called with
the nonnull assertion in some case where it currently is not.  I expect
this is one of the calls from cvt.c -- two do not assert nonnull and one
does.

	I am unsure whether one unilaterally should assert nonnull in a
case where it currently is not being asserted or whether one of the
functions that calls build_vbase_path() needs some additional information
to know that it is being called internally (e.g., for the example I
presented in the previous message).  I suspect it is the latter case.

	I could grovel around for this, but I do not know all of the
assumptions in the current call chains or all of the implications of a
change to any of them (other calls to cvt.c functions).  I was wondering
if any of the G++ experts can give me some more guidance about what I
should be looking for.

Thanks, David



More information about the Gcc mailing list