A patch to constify gcc.c (Really, summarizing remaining warnings)
Kaveh R. Ghazi
ghazi@caip.rutgers.edu
Thu Mar 11 09:01:00 GMT 1999
> From: Zack Weinberg <zack@rabi.columbia.edu>
>
> On Thu, 11 Mar 1999 11:08:45 -0500 (EST), "Kaveh R. Ghazi" wrote:
> > I attempted to figure this out myself and I poked around one
> >of the places where the warning occurs. One triggering site is in
> >cse.c:simplify_relational_operation, where it calls setjmp(). The
> >particular code in question does this:
> >
> > > else if (GET_CODE (op0) == CONST_DOUBLE && GET_CODE (op1) == CONST_DOUBLE
> > > && GET_MODE_CLASS (GET_MODE (op0)) == MODE_FLOAT)
> > > {
> > > REAL_VALUE_TYPE d0, d1;
> > > jmp_buf handler;
> > >
> > > if (setjmp (handler))
> > > return 0;
> > >
> > > set_float_handler (handler);
> > > REAL_VALUE_FROM_CONST_DOUBLE (d0, op0);
> > > REAL_VALUE_FROM_CONST_DOUBLE (d1, op1);
> > > equal = REAL_VALUES_EQUAL (d0, d1);
> > > op0lt = op0ltu = REAL_VALUES_LESS (d0, d1);
> > > op1lt = op1ltu = REAL_VALUES_LESS (d1, d0);
> > > set_float_handler (NULL_PTR);
> > > }
>
> I bet something like this will have the same effect as rth's suggestion:
>
> {
> jmp_buf handler;
>
> if (setjmp (handler))
> return 0;
>
> set_float_handler (handler);
> {
> REAL_VALUE_TYPE d0, d1;
>
> REAL_VALUE_FROM_CONST_DOUBLE (d0, op0);
> REAL_VALUE_FROM_CONST_DOUBLE (d1, op1);
> equal = REAL_VALUES_EQUAL (d0, d1);
> op0lt = op0ltu = REAL_VALUES_LESS (d0, d1);
> op1lt = op1ltu = REAL_VALUES_LESS (d1, d0);
> }
> set_float_handler (NULL_PTR);
> }
>
> d0 and d1 are out of scope of the longjmp target, so it should be
> clear to gcc that we don't care about the values if we jump.
> zw
That doesn't fix the warnings. In this case, gcc is warning about
arguments of the enclosing function, not the local variables `d0' and `d1'.
See below:
> cse.c: In function `simplify_relational_operation':
> cse.c:4607: warning: argument `code' might be clobbered by `longjmp' or `vfork'
> cse.c:4609: warning: argument `op0' might be clobbered by `longjmp' or `vfork'
> cse.c:4609: warning: argument `op1' might be clobbered by `longjmp' or `vfork'
--
Kaveh R. Ghazi Engagement Manager / Project Services
ghazi@caip.rutgers.edu Qwest Internet Solutions
More information about the Gcc-patches
mailing list