This is the mail archive of the gcc-patches@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]
Other format: [Raw text]

Re: [patch] 2 patches for PR tree-optimization/34648


double square_root (double x)
{
 if (x < 0)
   throw bad_arg();
 else
   return std::sqrt (x);
}

So it may or may not throw, but it will do so consistently depending on its arguments. If it's pure, it will throw consistently depending on its arguments and memory.

Are you sure this makes sense? The act of throwing an exception writes to (thread local) memory.

Not necessarily. If the handler is above the caller in the stack, we don't care because the function stops executing. If the handler is in the caller and is a no-op, the write will not be visible to the program. If the handler is in the caller and has side effects, they will be captured by the CFG and by PRE's dataflow solver.


Paolo


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