C++ PATCH: PR c++/7228

Mike Stump mrs@apple.com
Wed Oct 23 19:21:00 GMT 2002


I'd be interested in know if we can just check to see if the field 
exists first before grabbing it.  From a random 2 second search:

       if ((!COMPLETE_TYPE_P (inner_type) && CLASS_TYPE_P (inner_type))
	  /* RTTI TD entries are created while defining the type_info.  */
	  || (TYPE_LANG_SPECIFIC (inner_type)
	      && TYPE_BEING_DEFINED (inner_type)))
	incomplete_vars = tree_cons (inner_type, var, incomplete_vars);

Or, even more compelling:

	      else if (TYPE_LANG_SPECIFIC (TREE_TYPE (field))
		       && CLASSTYPE_READONLY_FIELDS_NEED_INIT (TREE_TYPE (field)))
		error ("member `%D' with uninitialized const fields",
			  field);

(I just worry about chewing up more memory, when maybe we don't have 
to.)

I don't know which I prefer if both can work.  I guess, it would be 
which ever one is fastest for most C++ code.  :-)

This question shouldn't block this patch, but it just me wondering 
aloud which way is better, I can't say that I know.

On Wednesday, October 23, 2002, at 06:42 PM, David Edelsohn wrote:
> 	I guess I should explain this patch a little.
> cp/decl.c:check_initializers applies 
> CLASSTYPE_READONLY_FIELDS_NEED_INIT
> to all types matching IS_AGGR_TYPE.  LANG_TYPE_CLASS_CHECK wants to 
> look
> at the lang_type structure.  That means that anything which matches
> IS_AGGR_TYPE must have a lang_type structure or LANG_TYPE_CLASS_CHECK 
> will
> dereference a NULL pointer.



More information about the Gcc-patches mailing list