[PATCH] Fix -Werror bootstrap problem with gcc 4.1 host compiler

Mark Mitchell mark@codesourcery.com
Mon Feb 5 04:32:00 GMT 2007


Dirk Mueller wrote:
> On Friday, 2. February 2007 17:59, Andi Kleen wrote:
> 
>> I needed this patch to bootstrap with a gcc 4.1 host compiler. Otherwise
>> -Werror would error out because gcc would think bases can be used
>> uninitialized.
> 
> this is PR bootstrap/30510. Patches have been posted several times already.

Interesting.  The first (and nearly immediate) use of bases is to take
its address and pass it to cp_parser_class_head, which is supposed to
initialize it.  There is a patch through cp_parser_class_head that
doesn't initialize bases, but in that case I think the return value will
always be such that we never try to use bases in the parent.  But,
still, this is unnecessarily playing with fire.

At some point, the "bases" parameter was added to cp_parser_class_head,
but no comment was added for it.  So, it's not clear whether callers or
expected to initialize it, or whether it is the responsibility of
cp_parser_class_head itself to do so.

Since there's only one caller, it doesn't matter; the separation between
caller and callee is mostly for documentation, in that "class-head" is a
separate non-terminal in the C++ grammar.  However, in keeping with the
handling of the other parameters to cp_parser_class_head, I think it's
best for this to be initialized in the callee.

Therefore, I think the best fix is to initialized bases in
cp_parser_class_head, along with adding documentation for the parameter.

I think the following documentation would be good:

  /* Upon return BASES is initialized to the list of base classes (or
NULL, if there are none) in the same form returned by
cp_parser_base_clause.  */

Would one of you be willing to test such a patch?  It's pre-approved,
assuming it works.

Thanks,

-- 
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713



More information about the Gcc-patches mailing list