tree-outof-ssa can move potentially-trapping operations across what were
sequence points, even when compiled with -fnon-call-exceptions.  E.g.,
consider the following C++ code, compiled with -fnon-call-exceptions:

------------------------------------------------------------------------
#include <stdio.h>

void foo (int) { printf ("Bar\n"); }

int
main (void)
{
  int a = 1 / 0;
  printf ("Foo\n");
  foo (a);
}
------------------------------------------------------------------------

The tree optimisers themselves preserve the intent of the code,
but tree-outof-ssa.c propogates the division into the call to foo():

------------------------------------------------------------------------
int main() ()
{
<bb 2>:
  __builtin_puts (&"Foo"[0]);
  foo (1 / 0);
  return 0;

}
------------------------------------------------------------------------

So the unoptimised program behaves as expected, raising the divide-by-zero
trap before printing "Foo".  The optimised version prints "Foo" first.


-- 
           Summary: tree-outof-ssa moves sources of non-call exceptions past
                    sequence points
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: treelang
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: rsandifo at gcc dot gnu dot org
 GCC build triplet: x86_64-linux-gnu
  GCC host triplet: x86_64-linux-gnu
GCC target triplet: x86_64-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33593

Reply via email to