[lto] Fix bootstrap failure

Doug Kwan (關振德) dougkwan@google.com
Thu Sep 4 19:13:00 GMT 2008


Commited this as obvious

2008-09-04  Doug Kwan  <dougkwan@google.com>

        * cgraph.c (cgraph_inlined_failed_string): Cast REASON from
        implementation-defined integer type to unsigned before comparison.

Index: cgraph.c
===================================================================
--- cgraph.c	(revision 139992)
+++ cgraph.c	(working copy)
@@ -1561,7 +1561,9 @@
 #include "cif-code.def"
   };

-  gcc_assert (reason < CIF_N_REASONS);
+  /* Signedness of an enum type is implementation defined, so cast it
+     to unsigned before testing. */
+  gcc_assert ((unsigned) reason < CIF_N_REASONS);
   return cif_string_table[reason];
 }


2008/9/4 Doug Kwan (關振德) <dougkwan@google.com>:
> Thanks for fixing that.  Unfortunately enum is not always unsigned:
>
> C99 6.7.2.2 (3)
>
> Each enumerated type shall be compatible with an integer type. The
> choice of type is
> implementation-defined,99) but shall be capable of representing the
> values of all the
> members of the enumeration. The enumerated type is incomplete until
> after the}that
> terminates the list of enumerator declarations.
>
> Removing the test is fine but it will not catch an error if some
> version of gcc picks a signed type to represent the enums.  Maybe we
> should cast it to unsigned first and then test like:
>
> gcc_assert ((unsigned) reason < CIF_N_REASON);
>
> -Doug
>
>
> 2008/9/4 Diego Novillo <dnovillo@google.com>:
>> No need to assert that an unsigned is >= 0.  This was causing a Werror
>> failure during stage2.
>>
>>
>> Tested on x86_64.  Committed.
>>
>>
>> Diego.
>>
>> 2008-09-04  Diego Novillo  <dnovillo@google.com>
>>
>>        * cgraph.c (cgraph_inlined_failed_string): Fix always
>>        true comparison.
>>
>>
>> Index: cgraph.c
>> ===================================================================
>> --- cgraph.c    (revision 139983)
>> +++ cgraph.c    (working copy)
>> @@ -1561,7 +1561,7 @@ cgraph_inline_failed_string (cgraph_inli
>>  #include "cif-code.def"
>>   };
>>
>> -  gcc_assert (reason >= CIF_OK && reason < CIF_N_REASONS);
>> +  gcc_assert (reason < CIF_N_REASONS);
>>   return cif_string_table[reason];
>>  }
>>
>


More information about the Gcc-patches mailing list