public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/52448] New: [4.4/4.5/4.6/4.7 Regression] cselim broken with calls
@ 2012-03-01 11:05 jakub at gcc dot gnu.org
  2012-03-01 11:22 ` [Bug tree-optimization/52448] " rguenth at gcc dot gnu.org
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-03-01 11:05 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 52448
           Summary: [4.4/4.5/4.6/4.7 Regression] cselim broken with calls
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: jakub@gcc.gnu.org


extern void abort (void);
extern void *malloc (__SIZE_TYPE__);
extern void free (void *);

__attribute__((noinline, noclone)) void
bar (char *x, int y)
{
  if (*x != '\n')
    abort ();
  if (y == 0)
    free (x);
}

__attribute__((noinline, noclone)) void
foo (char *x, int y)
{
  *x = '\n';
  bar (x, y);
  if (y)
    *x = '\0';
}

int
main ()
{
  char *p = malloc (1);
  if (p)
    {
      foo (p, 1);
      if (*p != '\0')
        abort ();
      foo (p, 0);
    }
  return 0;
}

The above testcase is miscompiled, starting with 4.3 with just -O2, before that
(including 3.2) with -O2 -ftree-cselim.  If you run the testcase under
valgrind, it will complain loudly, I could rewrite it (less portably) using
mmap/munmap to show it crash even without valgrind.

I'm afraid we need to invalidate the set of non-trapping MEMs on non-pure/const
calls (perhaps with the exception of selected builtins, e.g. none of the
string/mem builtins should actually unmap/mprotect/free any memory).


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

end of thread, other threads:[~2022-01-05 10:17 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-01 11:05 [Bug tree-optimization/52448] New: [4.4/4.5/4.6/4.7 Regression] cselim broken with calls jakub at gcc dot gnu.org
2012-03-01 11:22 ` [Bug tree-optimization/52448] " rguenth at gcc dot gnu.org
2012-03-01 12:06 ` matz at gcc dot gnu.org
2012-03-01 12:12 ` rguenth at gcc dot gnu.org
2012-03-01 12:58 ` matz at gcc dot gnu.org
2012-03-01 14:10 ` matz at gcc dot gnu.org
2012-03-01 16:08 ` matz at gcc dot gnu.org
2012-03-13 15:36 ` [Bug tree-optimization/52448] [4.5/4.6/4.7/4.8 " jakub at gcc dot gnu.org
2012-07-02 12:27 ` rguenth at gcc dot gnu.org
2013-01-10 16:49 ` [Bug tree-optimization/52448] [4.6/4.7/4.8 " jakub at gcc dot gnu.org
2013-02-08 12:32 ` matz at gcc dot gnu.org
2013-02-08 12:54 ` [Bug tree-optimization/52448] [4.6/4.7 " rguenth at gcc dot gnu.org
2013-04-12 15:18 ` [Bug tree-optimization/52448] [4.7 " jakub at gcc dot gnu.org
2014-06-12 13:05 ` rguenth at gcc dot gnu.org
2022-01-05 10:17 ` pinskia at gcc dot gnu.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).