This is the mail archive of the
mailing list for the GCC project.
Re: A patch to constify gcc.c (Really, summarizing remaining warnings)
- To: law at cygnus dot com, rth at cygnus dot com, zack at rabi dot columbia dot edu
- Subject: Re: A patch to constify gcc.c (Really, summarizing remaining warnings)
- From: "Kaveh R. Ghazi" <ghazi at caip dot rutgers dot edu>
- Date: Thu, 11 Mar 1999 11:08:45 -0500 (EST)
- Cc: egcs-patches at cygnus dot com
> From: Richard Henderson <firstname.lastname@example.org>
> On Thu, Mar 11, 1999 at 12:05:31AM -0700, Jeffrey A Law wrote:
> > We use setjmp/longjmp in a few places when we're going to be
> > messing around with floating point. They are necessary.
> The best way to fix the warning (and clean up the flow graph of the
> containing function, btw) is to always do things with a wrapper. E.g.
> int do_float_handler (void (*fn)(void *data), void *data)
> jmp_buf buf;
> if (setjmp (buf) != 0)
> return 0;
> set_float_handler (buf);
> set_float_handler (NULL);
> return 1;
This looks interesting, but I'm not sure I get it. Would you
please be more specific about how this would work? Where would
do_float_handler() be called from and with what values in its
parameters? What code would it substitute for?
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);
How would you transform this to use do_float_handler()?
I guess you could create a new function out of the code in between the
two calls to set_float_handler() and pass that function pointer to
do_float_handler(). Then if do_float_handler() returned 0, you'd
return 0? How would you pass all the necessary data in a void *?
Would you create a customized struct with all the info passed in and
out and then call do_float_handler() with the struct as the second
Also, let's assume what I describe above is accurate and we did
it. Out of curiosity, if I happened to bootstrap with -O3, and then
do_float_handler() is inlined, would the errors come back?
Kaveh R. Ghazi Engagement Manager / Project Services
email@example.com Qwest Internet Solutions