public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/30252]  New: [4.2/4.3 regression] miscompilation of sigc++-2.0 based code with -fstrict-aliasing
@ 2006-12-18 15:56 belyshev at depni dot sinp dot msu dot ru
  2006-12-18 15:57 ` [Bug tree-optimization/30252] " belyshev at depni dot sinp dot msu dot ru
                   ` (42 more replies)
  0 siblings, 43 replies; 44+ messages in thread
From: belyshev at depni dot sinp dot msu dot ru @ 2006-12-18 15:56 UTC (permalink / raw)
  To: gcc-bugs

gcc miscompiles this testcase (reduced from rtorrent) since r111639, compile
with -O1 -fstrict-aliasing:

#include <sigc++/bind.h>
#include <sigc++/slot.h>

static long dummy;

struct A
{
  static void *foo (void *p) { return p; }
  typedef sigc::slot <void *> C;
  C bar();
};

A::C A::bar ()
{
  return sigc::bind (sigc::ptr_fun (&A::foo), &dummy);
}

int main (void)
{
  A a;
  if (a.bar ()() != &dummy)
    abort ();
  return 0;
}


The program will crash in operator() because we store garbage instead of
function pointer inside A::bar():

--- O1  2006-12-18 18:44:34.000000000 +0300
+++ O1-fstrict-aliasing 2006-12-18 18:44:41.000000000 +0300
@@ -248,8 +248,8 @@
        movq    sigc::internal::typed_slot_rep<sigc::bind_functor<-1,
sigc::pointer_functor1<void*, void*>, long*, sigc::nil, sigc::nil, sigc::nil,
sigc::nil, sigc::nil, sigc::nil> >::dup(void*), 24(%rbx)
        movq    $0, 32(%rbx)
        movq    $0, 40(%rbx)
+       movq    %rbx, 64(%rbx)
        movq    $dummy, 72(%rbx)
-       movq    A::foo(void*), 64(%rbx)
        movq    %rbx, (%rsp)
        leaq    48(%rbx), %rsi
        movq    %rsp, %rdi

I will attach preprocessed and somewhat reduced testcase in a moment.

Caused by this patch:

Index: gcc/ChangeLog
===================================================================
--- gcc/ChangeLog       (revision 111638)
+++ gcc/ChangeLog       (revision 111639)
@@ -1,3 +1,8 @@
+2006-03-02  Richard Guenther  <rguenther@suse.de>
+
+       * tree-ssa-alias.c (find_used_portions): Consider taking
+       the address as making the variable not write-only.
+
 2006-03-02  Nick Clifton  <nickc@redhat.com>

        * config.gcc (default_use_cxa_atexit): Extend the description of
Index: gcc/tree-ssa-alias.c
===================================================================
--- gcc/tree-ssa-alias.c        (revision 111638)
+++ gcc/tree-ssa-alias.c        (revision 111639)
@@ -3071,6 +3071,8 @@ find_used_portions (tree *tp, int *walk_
            up->minused = 0;
            up->maxused = TREE_INT_CST_LOW (DECL_SIZE (var));
            up->implicit_uses = true;
+           if (!lhs_p)
+             up->write_only = false;

            up_insert (uid, up);
            *walk_subtrees = 0;


-- 
           Summary: [4.2/4.3 regression] miscompilation of sigc++-2.0 based
                    code with -fstrict-aliasing
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: belyshev at depni dot sinp dot msu dot ru


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


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

end of thread, other threads:[~2007-06-19  9:46 UTC | newest]

Thread overview: 44+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-12-18 15:56 [Bug tree-optimization/30252] New: [4.2/4.3 regression] miscompilation of sigc++-2.0 based code with -fstrict-aliasing belyshev at depni dot sinp dot msu dot ru
2006-12-18 15:57 ` [Bug tree-optimization/30252] " belyshev at depni dot sinp dot msu dot ru
2006-12-18 18:24 ` pinskia at gcc dot gnu dot org
2006-12-18 19:04 ` pinskia at gcc dot gnu dot org
2006-12-19 11:11 ` [Bug tree-optimization/30252] [4.2 " belyshev at depni dot sinp dot msu dot ru
2006-12-27 16:18 ` rguenth at gcc dot gnu dot org
2006-12-27 20:19 ` belyshev at depni dot sinp dot msu dot ru
2007-02-19 20:52 ` mmitchel at gcc dot gnu dot org
2007-04-29  7:02 ` pinskia at gcc dot gnu dot org
2007-04-29  8:58 ` belyshev at depni dot sinp dot msu dot ru
2007-04-30  2:25 ` bangerth at dealii dot org
2007-04-30 14:16 ` pluto at agmk dot net
2007-04-30 14:29 ` pluto at agmk dot net
2007-04-30 14:43 ` bangerth at dealii dot org
2007-05-01  1:11 ` giovannibajo at libero dot it
2007-05-01  1:39 ` bangerth at math dot tamu dot edu
2007-05-01  7:59 ` pluto at agmk dot net
2007-05-01 12:35 ` rguenth at gcc dot gnu dot org
2007-05-01 13:01 ` rguenth at gcc dot gnu dot org
2007-05-01 13:05 ` [Bug c++/30252] " rguenth at gcc dot gnu dot org
2007-05-02 20:59 ` mmitchel at gcc dot gnu dot org
2007-05-13  0:43 ` ismail at pardus dot org dot tr
2007-05-13 10:34 ` rguenth at gcc dot gnu dot org
2007-05-13 12:02 ` rguenth at gcc dot gnu dot org
2007-05-14 19:04 ` dberlin at gcc dot gnu dot org
2007-05-14 21:26 ` mmitchel at gcc dot gnu dot org
2007-05-15  7:59 ` rguenth at gcc dot gnu dot org
2007-06-04 15:28 ` rguenth at gcc dot gnu dot org
2007-06-04 15:45 ` rguenth at gcc dot gnu dot org
2007-06-05  9:27 ` rguenth at gcc dot gnu dot org
2007-06-05 12:05 ` rguenth at gcc dot gnu dot org
2007-06-05 15:01 ` rguenth at gcc dot gnu dot org
2007-06-05 15:57 ` rguenth at gcc dot gnu dot org
2007-06-05 16:20 ` dberlin at dberlin dot org
2007-06-05 16:30 ` rguenther at suse dot de
2007-06-05 17:45 ` dberlin at dberlin dot org
2007-06-05 18:25 ` matz at gcc dot gnu dot org
2007-06-05 19:07 ` dberlin at dberlin dot org
2007-06-05 19:59 ` rguenther at suse dot de
2007-06-05 22:44 ` dberlin at dberlin dot org
2007-06-06  8:50 ` rguenther at suse dot de
2007-06-06 15:52 ` dberlin at dberlin dot org
2007-06-19  9:24 ` rguenth at gcc dot gnu dot org
2007-06-19  9:46 ` rguenth 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).