This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Functions that always return


On Sun, Oct 29, 2000 at 12:12:19PM -0500, Richard Kenner wrote:
>     Well, so long as you don't mind if stuff that can potentially
>     trap being moved across these functions.  If you do care, you
>     can't mark anything constant.
> 
> Note the scenario here: an Ada procedure X calls a C++ function A,
> which calls a constant function B (also in C++) and B gets a stack
> overflow.  That will cause a Storage_Error exception which, if caught
> at all, will be in X or above.
> 
> Can you explain what you mean in conjuction with this scenario?

In conjunction with this scenario, I don't mean anything.  Since
A is not constant, anything can happen.

The scenario I have in mind is a loop that contains a constant
function (with non-invariant arguments, so it doesn't get hoisted),
followed by, say, a division with invariant arguments.  Since the
function is constant, it is "guaranteed to return", so the 
division will "always" be executed, so we are allowed to hoist 
it outside the loop.

If the function were not constant, we could not hoist the division
because the function might decide to terminate gracefully rather
than be killed by the division by zero that it knows is coming.


r~

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]