public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug treelang/33593]  New: tree-outof-ssa moves sources of non-call exceptions past sequence points
@ 2007-09-29 19:01 rsandifo at gcc dot gnu dot org
  2007-09-29 19:05 ` [Bug tree-optimization/33593] " pinskia at gcc dot gnu dot org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: rsandifo at gcc dot gnu dot org @ 2007-09-29 19:01 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2008-02-03 14:36 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-09-29 19:01 [Bug treelang/33593] New: tree-outof-ssa moves sources of non-call exceptions past sequence points rsandifo at gcc dot gnu dot org
2007-09-29 19:05 ` [Bug tree-optimization/33593] " pinskia at gcc dot gnu dot org
2007-09-29 19:05 ` rsandifo at gcc dot gnu dot org
2007-09-29 19:08 ` dnovillo at google dot com
2007-09-29 19:08 ` pinskia at gcc dot gnu dot org
2007-09-30 16:00 ` dnovillo at gcc dot gnu dot org
2008-02-03 14:36 ` steven at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).