3 msgTest Coverage not on whole execution (gcov)
12 msgWeird result for modulus operation
2 msgDatabase for GCC
2 msgFwd: gcc cross compiler problem
1 msggcc-4.1-20080428 is now available
1 msgmapping liveness to variables
5 msgAre x86 builtin load functions 'const'?
9 msg[RFC] Modeling the behavior of function calls
1 msgGCC performance with CP2K
2 msgSzia.
2 msgMetrication tool
4 msgCode representations

[switch conv] Bootsrap error because of the (CE...
\ Martin Jambor (28 Apr 2008)
. \ Ian Lance Taylor (29 Apr 2008)
. . \ Martin Jambor (30 Apr 2008)

11 msgRedundant malloc in structure optimization? (te...
2 msgImplementing built-in functions for I/O
2 msgabsolutely FREE web-search OSN service for your...
8 msgFailure in bootstrapping gfortran-4.4.0-2008042...
1 msgWeb page additon
1 msg4.3.0 build report
1 msg[tuples] Mainline merge @134692
Subject:[switch conv] Bootsrap error because of the (CERT) pointer wraparound warning
Group:Gcc
From:Martin Jambor
Date:28 Apr 2008


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


© 2004-2008 readlist.com