[lto] Fix bootstrap failure

Gerald Pfeifer gerald@pfeifer.com
Thu Sep 4 22:41:00 GMT 2008


On Thu, 4 Sep 2008, Diego Novillo wrote:
> No need to assert that an unsigned is >= 0.  This was causing a Werror
> failure during stage2.
> [...]
> -  gcc_assert (reason >= CIF_OK && reason < CIF_N_REASONS);
> +  gcc_assert (reason < CIF_N_REASONS);
>    return cif_string_table[reason];
>  }

This actually shows a real weakness of our warning system which I also
ran into in some other context (with the Wine project).

What if, for some reason, someone later sets CIF_OK=42?  The assert as 
written makes sense, except that with the current values of the enum the
the first part is optimized away.  By manually optimizing this to avoid
the warning, the check becomes (potentially) less robust.

Any ideas how we could address this in a better way (in general, not for
this specific example necessarily)?

Perhaps not warn in case the constant is 0U as opposed to 0?

Not warn if an enum variable is compared against one of it's symbolic
values?

Gerald



More information about the Gcc-patches mailing list