Hi, I've been rebootstrapping my switch conversion patch (which is still waiting for review) to make sure it still works. Unfortunately, it did not. The error given was the following and I believe this is the warning introduced by Ian as a response to the infamous CERT advisory. (Furthermore, I am getting this warning at revision 134664 but I was not getting it at 134135.)
------- Compiler output ------- /cswtch/gcc/. -I/abuild/mjambor/cswtch/gcc/../include -I/abuild/mjambor/cswtch/gcc/../libcpp/include -I/abuild/mjambor/cswtch/gcc/../libdecnumber -I/abuild/mjambor/cswtch/gcc/../libdecnumber/bid -I../libdecnumber /abuild/mjambor/cswtch/gcc/tree-switch-conversion.c -o tree-switch-conversion.o cc1: warnings being treated as errors /abuild/mjambor/cswtch/gcc/tree-switch-conversion.c: In function 'process_switch': /abuild/mjambor/cswtch/gcc/tree-switch-conversion.c:182: error: assuming signed overflow does not occur when assuming that (X - c) > X is always false make[3]: *** [tree-switch-conversion.o] Error 1 ------------- End ------------- The whole switch conversion patch can be found at: http://gcc.gnu.org/ml/gcc-patches/2008-04/msg00863.html. The code that triggers the warning is the following, line 182 is the last one in this snippet: static bool check_range (tree swtch) /* swtch is a SWITCH_EXPR */ { tree min_case, max_case; tree cases = SWITCH_LABELS (swtch); int branch_num = TREE_VEC_LENGTH (cases); min_case = TREE_VEC_ELT (cases, 0); info.range_min = CASE_LOW (min_case); gcc_assert (branch_num > 1); gcc_assert (CASE_LOW (TREE_VEC_ELT (cases, branch_num - 1)) == NULL_TREE); max_case = TREE_VEC_ELT (cases, branch_num - 2); Now the fundamental question is, am I doing something wrong? My best guess is that this is only a very unfortunate bogus instance of the warning. When checking is not enabled, TREE_VEC_ELT(T, I) is expanded to ((T)->vec.a[I]) and given that branch_num holds the number of vector elements, I am certainly accessing an item inside the array. On the contrary, bootstrapping is done with checking on and so TREE_VEC_ELT expands to much more complex thing: #define TREE_VEC_ELT_CHECK(T, I) __extension__ \ (*({__typeof (T) const __t = (T); \ const int __i = (I); \ if (TREE_CODE (__t) != TREE_VEC) \ tree_check_failed (__t, __FILE__, __LINE__, __FUNCTION__, \ TREE_VEC, 0); \ if (__i < 0 || __i >= __t->vec.length) \ tree_vec_elt_check_failed (__i, __t->vec.length, \ __FILE__, __LINE__, __FUNCTION__); \ &__t->vec.a[__i]; })) And I guess that the second condition triggers the warning which is then treated like an error. Having said the above, I do not know why the TREE_VEC_ELT on the previous line does not trigger the warning. In the end, I basically have these questions: 1. Am I doing something wrong? 2. How can I get rid of the error and bootstrap my code? 3. If the warning is really bogus, should we perhaps turn it off for bootstrap, (or turn it off by default in general and leave it there for people who want to check their code after reading CERT advisories)? Thank you, Martin