public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/24172]  New: error: incorrect sharing of tree nodes
@ 2005-10-03  1:06 kev dot gilbert at cdu dot edu dot au
  2005-10-03  1:10 ` [Bug tree-optimization/24172] [4.1 Regression] " pinskia at gcc dot gnu dot org
                   ` (16 more replies)
  0 siblings, 17 replies; 18+ messages in thread
From: kev dot gilbert at cdu dot edu dot au @ 2005-10-03  1:06 UTC (permalink / raw)
  To: gcc-bugs

Compile of KOffice with gcc4.1 failed.  Source condensed to a test case which
produces the following error:

---------------
test-case-1.cpp: In function ‘void prepare_inpaint()’:
test-case-1.cpp:55: error: incorrect sharing of tree nodes
D.1986_15 = "rb"[0];

"rb"[0];

test-case-1.cpp:55: internal compiler error: verify_stmts failed
---------------

gcc version info:

---------------
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ./configure
Thread model: posix
gcc version 4.1.0 20050927 (experimental)
---------------

Compile command:

---------------
g++ -O2 -c test-case-1.cpp
---------------

The compile fails with O1, O2 and O3 but works with O0. Source code of test
case (note: I could not reduce it any further) :

---------------
namespace cimg_library
{       template<typename T = float> struct CImg;
        template<typename T = float> struct CImgl;

        struct Exception
        {
        };

        struct IOException : Exception
        {       IOException( const char * )
                {
                }
        };

        namespace cimg
        {       inline int* dummy( const char* const path, const char* const
mode )
                {       throw IOException( mode[ 0 ] == 'r' ? "a" : (mode[ 0 ]
== 'w' ? "b" : "" ));
                        return 0;
                }

        }

        template<typename T> struct CImg
        {       T *data;

                explicit CImg( const unsigned int dx = 0 )
                {
                }

                CImg( const char *filename )
                {       CImgl<T>( filename ).get_append( 'v', 'p' );
                }
        };

        template<typename T> struct CImgl
        {       CImgl( const unsigned int )
                {
                }

                CImgl(const char* filename)
                {       cimg::dummy( filename, "rb" );
                        unsigned int n;
                        CImgl<T> res( n );
                }

                CImg<T> get_append( const char, const char ) const
                {       CImg<T> res;
                        return res;
                }
        };
}

using namespace cimg_library;

void prepare_inpaint( )
{       cimg_library::CImg<unsigned char> mask = CImg<unsigned char>( "" );
}
---------------


-- 
           Summary: error: incorrect sharing of tree nodes
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: kev dot gilbert at cdu dot edu dot au
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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


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

* [Bug tree-optimization/24172] [4.1 Regression] error: incorrect sharing of tree nodes
  2005-10-03  1:06 [Bug c++/24172] New: error: incorrect sharing of tree nodes kev dot gilbert at cdu dot edu dot au
@ 2005-10-03  1:10 ` pinskia at gcc dot gnu dot org
  2005-10-03  1:13 ` pinskia at gcc dot gnu dot org
                   ` (15 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-10-03  1:10 UTC (permalink / raw)
  To: gcc-bugs



-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|c++                         |tree-optimization
           Keywords|                            |ice-on-valid-code
      Known to fail|                            |4.1.0
      Known to work|                            |4.0.0
            Summary|error: incorrect sharing of |[4.1 Regression] error:
                   |tree nodes                  |incorrect sharing of tree
                   |                            |nodes
   Target Milestone|---                         |4.1.0


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


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

* [Bug tree-optimization/24172] [4.1 Regression] error: incorrect sharing of tree nodes
  2005-10-03  1:06 [Bug c++/24172] New: error: incorrect sharing of tree nodes kev dot gilbert at cdu dot edu dot au
  2005-10-03  1:10 ` [Bug tree-optimization/24172] [4.1 Regression] " pinskia at gcc dot gnu dot org
@ 2005-10-03  1:13 ` pinskia at gcc dot gnu dot org
  2005-10-03  1:26 ` pinskia at gcc dot gnu dot org
                   ` (14 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-10-03  1:13 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2005-10-03 01:12 -------
This is caused by the inliner.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hubicka at gcc dot gnu dot
                   |                            |org


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


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

* [Bug tree-optimization/24172] [4.1 Regression] error: incorrect sharing of tree nodes
  2005-10-03  1:06 [Bug c++/24172] New: error: incorrect sharing of tree nodes kev dot gilbert at cdu dot edu dot au
  2005-10-03  1:10 ` [Bug tree-optimization/24172] [4.1 Regression] " pinskia at gcc dot gnu dot org
  2005-10-03  1:13 ` pinskia at gcc dot gnu dot org
@ 2005-10-03  1:26 ` pinskia at gcc dot gnu dot org
  2005-10-03 16:54 ` pinskia at gcc dot gnu dot org
                   ` (13 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-10-03  1:26 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pinskia at gcc dot gnu dot org  2005-10-03 01:26 -------
Here is a slightly shorter testcase:


template<typename T = float> struct CImg;
        template<typename T = float> struct CImgl;
        struct IOException
        {       IOException( const char * ){}
        };
  inline int* dummy( const char* const path, const char* const
mode )
                {       throw IOException( mode[ 0 ] == 'r' ? "a" : (mode[ 0 ]
== 'w' ? "b" : "" ));
                }
        template<typename T> struct CImg
        {       T *data;
                explicit CImg( const unsigned int dx = 0 )
                {
                }
                CImg( const char *filename )
                {       CImgl<T>( filename ).get_append( 'v', 'p' );
                }
        };
        template<typename T> struct CImgl
        {       CImgl( const unsigned int )
                {
                }
                CImgl(const char* filename)
                {       dummy( filename, "rb" );
                        unsigned int n;
                       CImgl<T> res( n );
                }
                CImg<T> get_append( const char, const char ) const
                {       CImg<T> res;
                }
        };
void prepare_inpaint( )
{       CImg<unsigned char> mask = CImg<unsigned char>( "" );
}

---

I have not tried to reduce it further.


-- 


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


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

* [Bug tree-optimization/24172] [4.1 Regression] error: incorrect sharing of tree nodes
  2005-10-03  1:06 [Bug c++/24172] New: error: incorrect sharing of tree nodes kev dot gilbert at cdu dot edu dot au
                   ` (2 preceding siblings ...)
  2005-10-03  1:26 ` pinskia at gcc dot gnu dot org
@ 2005-10-03 16:54 ` pinskia at gcc dot gnu dot org
  2005-10-03 22:00 ` janis187 at us dot ibm dot com
                   ` (12 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-10-03 16:54 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from pinskia at gcc dot gnu dot org  2005-10-03 16:54 -------
Confirmed, reduced testcase:
void IOException( char);
inline int* dummy( const char* const mode )
{
  IOException(*mode+*mode);
}

void prepare_inpaint( )
{
  dummy ("rb");
}


The problem is that we have &"rb"[0] and we get *(&"rb"[0]) but we only fold
that to "rb"[0] instead of all the way to 'r'.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2005-10-03 16:54:18
               date|                            |


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


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

* [Bug tree-optimization/24172] [4.1 Regression] error: incorrect sharing of tree nodes
  2005-10-03  1:06 [Bug c++/24172] New: error: incorrect sharing of tree nodes kev dot gilbert at cdu dot edu dot au
                   ` (3 preceding siblings ...)
  2005-10-03 16:54 ` pinskia at gcc dot gnu dot org
@ 2005-10-03 22:00 ` janis187 at us dot ibm dot com
  2005-10-04 10:44 ` rguenth at gcc dot gnu dot org
                   ` (11 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: janis187 at us dot ibm dot com @ 2005-10-03 22:00 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from janis187 at us dot ibm dot com  2005-10-03 21:59 -------
A regression hunt using the testcase from comment #3 identified this patch from
hubicka@gcc.gnu.org:

  http://gcc.gnu.org/ml/gcc-cvs/2005-05/msg00624.html


-- 


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


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

* [Bug tree-optimization/24172] [4.1 Regression] error: incorrect sharing of tree nodes
  2005-10-03  1:06 [Bug c++/24172] New: error: incorrect sharing of tree nodes kev dot gilbert at cdu dot edu dot au
                   ` (4 preceding siblings ...)
  2005-10-03 22:00 ` janis187 at us dot ibm dot com
@ 2005-10-04 10:44 ` rguenth at gcc dot gnu dot org
  2005-10-04 11:00 ` rguenth at gcc dot gnu dot org
                   ` (10 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2005-10-04 10:44 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from rguenth at gcc dot gnu dot org  2005-10-04 10:44 -------
The problem is, that with this part of the blamed patch

===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-inline.c,v
retrieving revision 1.182
retrieving revision 1.183
diff -u -r1.182 -r1.183
--- gcc/gcc/tree-inline.c       2005/04/23 21:27:58     1.182
+++ gcc/gcc/tree-inline.c       2005/05/13 13:56:54     1.183
@@ -566,21 +566,15 @@
        {
          /* Get rid of *& from inline substitutions that can happen when a
             pointer argument is an ADDR_EXPR.  */
-         tree decl = TREE_OPERAND (*tp, 0), value;
+         tree decl = TREE_OPERAND (*tp, 0);
          splay_tree_node n;

          n = splay_tree_lookup (id->decl_map, (splay_tree_key) decl);
          if (n)
            {
-             value = (tree) n->value;
-             STRIP_NOPS (value);
-             if (TREE_CODE (value) == ADDR_EXPR
-                 && (lang_hooks.types_compatible_p
-                     (TREE_TYPE (*tp), TREE_TYPE (TREE_OPERAND (value, 0)))))
-               {
-                 *tp = TREE_OPERAND (value, 0);
-                 return copy_body_r (tp, walk_subtrees, data);
-               }
+             *tp = build_fold_indirect_ref ((tree)n->value);
+             *walk_subtrees = 0;
+             return NULL;
            }
        }

we do not have *tp unshared anymore.  Is build_fold_indirect_ref supposed
to do that?

Anyway, I'll test the following:

Index: tree-inline.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-inline.c,v
retrieving revision 1.210
diff -c -3 -p -r1.210 tree-inline.c
*** tree-inline.c       1 Aug 2005 15:25:28 -0000       1.210
--- tree-inline.c       4 Oct 2005 10:43:23 -0000
*************** copy_body_r (tree *tp, int *walk_subtree
*** 636,643 ****
                  else
                    *tp = build1 (INDIRECT_REF, type, (tree)n->value);
                }
!             *walk_subtrees = 0;
!             return NULL;
            }
        }

--- 636,642 ----
                  else
                    *tp = build1 (INDIRECT_REF, type, (tree)n->value);
                }
!             /* Fall through to copying the folded tree.  */
            }
        }


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |rguenth at gcc dot gnu dot
                   |dot org                     |org
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2005-10-03 16:54:18         |2005-10-04 10:44:04
               date|                            |


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


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

* [Bug tree-optimization/24172] [4.1 Regression] error: incorrect sharing of tree nodes
  2005-10-03  1:06 [Bug c++/24172] New: error: incorrect sharing of tree nodes kev dot gilbert at cdu dot edu dot au
                   ` (5 preceding siblings ...)
  2005-10-04 10:44 ` rguenth at gcc dot gnu dot org
@ 2005-10-04 11:00 ` rguenth at gcc dot gnu dot org
  2005-10-04 12:53 ` pinskia at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2005-10-04 11:00 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from rguenth at gcc dot gnu dot org  2005-10-04 11:00 -------
Other approach, make sure we fold it.  We don't have fold_build4, neither does
fold handle it.  But there's fold_read_from_constant_string.

Index: fold-const.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fold-const.c,v
retrieving revision 1.626
diff -c -3 -p -r1.626 fold-const.c
*** fold-const.c        26 Sep 2005 01:28:38 -0000      1.626
--- fold-const.c        4 Oct 2005 10:59:06 -0000
*************** fold_indirect_ref_1 (tree type, tree op0
*** 11511,11519 ****
      {
        tree op = TREE_OPERAND (sub, 0);
        tree optype = TREE_TYPE (op);
!       /* *&p => p */
        if (type == optype)
!       return op;
        /* *(foo *)&fooarray => fooarray[0] */
        else if (TREE_CODE (optype) == ARRAY_TYPE
               && type == TREE_TYPE (optype))
--- 11511,11525 ----
      {
        tree op = TREE_OPERAND (sub, 0);
        tree optype = TREE_TYPE (op);
!       /* *&p => p;  make sure to handle *&"str"[cst] here.  */
        if (type == optype)
!       {
!         tree fop = fold_read_from_constant_string (op);
!         if (fop)
!           return fop;
!         else
!           return op;
!       }
        /* *(foo *)&fooarray => fooarray[0] */
        else if (TREE_CODE (optype) == ARRAY_TYPE
               && type == TREE_TYPE (optype))


-- 


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


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

* [Bug tree-optimization/24172] [4.1 Regression] error: incorrect sharing of tree nodes
  2005-10-03  1:06 [Bug c++/24172] New: error: incorrect sharing of tree nodes kev dot gilbert at cdu dot edu dot au
                   ` (6 preceding siblings ...)
  2005-10-04 11:00 ` rguenth at gcc dot gnu dot org
@ 2005-10-04 12:53 ` pinskia at gcc dot gnu dot org
  2005-10-04 12:56 ` hubicka at ucw dot cz
                   ` (8 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-10-04 12:53 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from pinskia at gcc dot gnu dot org  2005-10-04 12:53 -------
(In reply to comment #6)
> Other approach, make sure we fold it.  We don't have fold_build4, neither does
> fold handle it.  But there's fold_read_from_constant_string.

I rather see this patch here than the first one for 4.1.  I also like to see a
lot of the code from tree-ccp.c for folding moved to the proper spot for 4.2.


-- 


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


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

* [Bug tree-optimization/24172] [4.1 Regression] error: incorrect sharing of tree nodes
  2005-10-03  1:06 [Bug c++/24172] New: error: incorrect sharing of tree nodes kev dot gilbert at cdu dot edu dot au
                   ` (7 preceding siblings ...)
  2005-10-04 12:53 ` pinskia at gcc dot gnu dot org
@ 2005-10-04 12:56 ` hubicka at ucw dot cz
  2005-10-04 13:42 ` rguenth at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: hubicka at ucw dot cz @ 2005-10-04 12:56 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from hubicka at ucw dot cz  2005-10-04 12:56 -------
Subject: Re:  [4.1 Regression] error: incorrect sharing of tree nodes

> 
> 
> ------- Comment #5 from rguenth at gcc dot gnu dot org  2005-10-04 10:44 -------
> The problem is, that with this part of the blamed patch
> 
> ===================================================================
> RCS file: /cvs/gcc/gcc/gcc/tree-inline.c,v
> retrieving revision 1.182
> retrieving revision 1.183
> diff -u -r1.182 -r1.183
> --- gcc/gcc/tree-inline.c       2005/04/23 21:27:58     1.182
> +++ gcc/gcc/tree-inline.c       2005/05/13 13:56:54     1.183
> @@ -566,21 +566,15 @@
>         {
>           /* Get rid of *& from inline substitutions that can happen when a
>              pointer argument is an ADDR_EXPR.  */
> -         tree decl = TREE_OPERAND (*tp, 0), value;
> +         tree decl = TREE_OPERAND (*tp, 0);
>           splay_tree_node n;
> 
>           n = splay_tree_lookup (id->decl_map, (splay_tree_key) decl);
>           if (n)
>             {
> -             value = (tree) n->value;
> -             STRIP_NOPS (value);
> -             if (TREE_CODE (value) == ADDR_EXPR
> -                 && (lang_hooks.types_compatible_p
> -                     (TREE_TYPE (*tp), TREE_TYPE (TREE_OPERAND (value, 0)))))
> -               {
> -                 *tp = TREE_OPERAND (value, 0);
> -                 return copy_body_r (tp, walk_subtrees, data);
> -               }
> +             *tp = build_fold_indirect_ref ((tree)n->value);
> +             *walk_subtrees = 0;
> +             return NULL;
>             }
>         }
> 
> we do not have *tp unshared anymore.  Is build_fold_indirect_ref supposed
> to do that?

It is not, but the entries of decl_map are expected to be shareable.
There are couple of other places where n->value is substituted in
without further copying.  I see there can be NOP_EXPRs and ADDR_EXPRs
that are supposed to be unshared.

We don't want to recurse on substituted value as we would mess up
recursive functions and friends, but probably somehing like unshare_expr
call on all places we dosubstitution would work?
I can look into that tomorrow unless someone beats me ;)

Honza


-- 


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


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

* [Bug tree-optimization/24172] [4.1 Regression] error: incorrect sharing of tree nodes
  2005-10-03  1:06 [Bug c++/24172] New: error: incorrect sharing of tree nodes kev dot gilbert at cdu dot edu dot au
                   ` (8 preceding siblings ...)
  2005-10-04 12:56 ` hubicka at ucw dot cz
@ 2005-10-04 13:42 ` rguenth at gcc dot gnu dot org
  2005-10-07  9:05 ` rguenth at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2005-10-04 13:42 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from rguenth at gcc dot gnu dot org  2005-10-04 13:42 -------
Patch posted.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                URL|                            |http://gcc.gnu.org/ml/gcc-
                   |                            |patches/2005-
                   |                            |10/msg00142.html
           Keywords|                            |patch


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


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

* [Bug tree-optimization/24172] [4.1 Regression] error: incorrect sharing of tree nodes
  2005-10-03  1:06 [Bug c++/24172] New: error: incorrect sharing of tree nodes kev dot gilbert at cdu dot edu dot au
                   ` (9 preceding siblings ...)
  2005-10-04 13:42 ` rguenth at gcc dot gnu dot org
@ 2005-10-07  9:05 ` rguenth at gcc dot gnu dot org
  2005-10-13 15:56 ` pinskia at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2005-10-07  9:05 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from rguenth at gcc dot gnu dot org  2005-10-07 09:05 -------
Honza, I'm stuck with rth's comment that there may be still sharing bugs even
after making fold_indirect_ref_1 fold the offending statement.  And as you
noted,
calling copy_body_r on the folded or unfolded tree causes either nice recursion
or the assert at tree-inline.c:665 to trigger.

So can you try either convince rth that just doing better folding is safe or
try your unshare_expr idea?

Thx,
Richard.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rguenth at gcc dot gnu dot
                   |                            |org
         AssignedTo|rguenth at gcc dot gnu dot  |hubicka at gcc dot gnu dot
                   |org                         |org


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


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

* [Bug tree-optimization/24172] [4.1 Regression] error: incorrect sharing of tree nodes
  2005-10-03  1:06 [Bug c++/24172] New: error: incorrect sharing of tree nodes kev dot gilbert at cdu dot edu dot au
                   ` (10 preceding siblings ...)
  2005-10-07  9:05 ` rguenth at gcc dot gnu dot org
@ 2005-10-13 15:56 ` pinskia at gcc dot gnu dot org
  2005-10-21 11:07 ` steven at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-10-13 15:56 UTC (permalink / raw)
  To: gcc-bugs



-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pinskia at gcc dot gnu dot
                   |                            |org
           Severity|normal                      |critical
  GCC build triplet|i686-pc-linux-gnu           |
   GCC host triplet|i686-pc-linux-gnu           |
 GCC target triplet|i686-pc-linux-gnu           |


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


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

* [Bug tree-optimization/24172] [4.1 Regression] error: incorrect sharing of tree nodes
  2005-10-03  1:06 [Bug c++/24172] New: error: incorrect sharing of tree nodes kev dot gilbert at cdu dot edu dot au
                   ` (11 preceding siblings ...)
  2005-10-13 15:56 ` pinskia at gcc dot gnu dot org
@ 2005-10-21 11:07 ` steven at gcc dot gnu dot org
  2005-10-21 12:19 ` rguenth at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: steven at gcc dot gnu dot org @ 2005-10-21 11:07 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #11 from steven at gcc dot gnu dot org  2005-10-21 11:07 -------
Honza, Richi... well?  Is anyone going to do anything with this bug? :-)


-- 

steven at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|2005-10-04 10:44:04         |2005-10-21 11:07:48
               date|                            |


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


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

* [Bug tree-optimization/24172] [4.1 Regression] error: incorrect sharing of tree nodes
  2005-10-03  1:06 [Bug c++/24172] New: error: incorrect sharing of tree nodes kev dot gilbert at cdu dot edu dot au
                   ` (12 preceding siblings ...)
  2005-10-21 11:07 ` steven at gcc dot gnu dot org
@ 2005-10-21 12:19 ` rguenth at gcc dot gnu dot org
  2005-10-27 21:18 ` hubicka at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2005-10-21 12:19 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #12 from rguenth at gcc dot gnu dot org  2005-10-21 12:19 -------
My fix to fold works and is in out beta compiler.


-- 


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


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

* [Bug tree-optimization/24172] [4.1 Regression] error: incorrect sharing of tree nodes
  2005-10-03  1:06 [Bug c++/24172] New: error: incorrect sharing of tree nodes kev dot gilbert at cdu dot edu dot au
                   ` (13 preceding siblings ...)
  2005-10-21 12:19 ` rguenth at gcc dot gnu dot org
@ 2005-10-27 21:18 ` hubicka at gcc dot gnu dot org
  2005-10-30 18:18 ` hubicka at gcc dot gnu dot org
  2005-10-30 21:59 ` hubicka at gcc dot gnu dot org
  16 siblings, 0 replies; 18+ messages in thread
From: hubicka at gcc dot gnu dot org @ 2005-10-27 21:18 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #13 from hubicka at gcc dot gnu dot org  2005-10-27 21:18 -------
This is patch I am testing to prevent the sharing.  I think it is good idea in
addition to Richard's patch to make fold do it's job too:

void IOException( char);
inline int* dummy( const char* const mode )
{
  IOException(*mode+*mode);
}

void prepare_inpaint( )
{
  dummy ("rb");
}


Index: tree-inline.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-inline.c,v
retrieving revision 1.212
diff -c -3 -p -r1.212 tree-inline.c
*** tree-inline.c       12 Oct 2005 23:34:09 -0000      1.212
--- tree-inline.c       27 Oct 2005 21:16:34 -0000
*************** copy_body_r (tree *tp, int *walk_subtree
*** 639,644 ****
--- 639,645 ----
          n = splay_tree_lookup (id->decl_map, (splay_tree_key) decl);
          if (n)
            {
+             tree new;
              /* If we happen to get an ADDR_EXPR in n->value, strip
                 it manually here as we'll eventually get ADDR_EXPRs
                 which lie about their types pointed to.  In this case
*************** copy_body_r (tree *tp, int *walk_subtree
*** 646,658 ****
                 but we absolutely rely on that.  As fold_indirect_ref
                 does other useful transformations, try that first, though.  */
              tree type = TREE_TYPE (TREE_TYPE ((tree)n->value));
!             *tp = fold_indirect_ref_1 (type, (tree)n->value);
              if (! *tp)
                {
!                 if (TREE_CODE ((tree)n->value) == ADDR_EXPR)
!                   *tp = TREE_OPERAND ((tree)n->value, 0);
                  else
!                   *tp = build1 (INDIRECT_REF, type, (tree)n->value);
                }
              *walk_subtrees = 0;
              return NULL;
--- 647,660 ----
                 but we absolutely rely on that.  As fold_indirect_ref
                 does other useful transformations, try that first, though.  */
              tree type = TREE_TYPE (TREE_TYPE ((tree)n->value));
!             new = unshare_expr ((tree)n->value);
!             *tp = fold_indirect_ref_1 (type, new);
              if (! *tp)
                {
!                 if (TREE_CODE (new) == ADDR_EXPR)
!                   *tp = TREE_OPERAND (new, 0);
                  else
!                   *tp = build1 (INDIRECT_REF, type, new);
                }
              *walk_subtrees = 0;
              return NULL;


-- 


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


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

* [Bug tree-optimization/24172] [4.1 Regression] error: incorrect sharing of tree nodes
  2005-10-03  1:06 [Bug c++/24172] New: error: incorrect sharing of tree nodes kev dot gilbert at cdu dot edu dot au
                   ` (14 preceding siblings ...)
  2005-10-27 21:18 ` hubicka at gcc dot gnu dot org
@ 2005-10-30 18:18 ` hubicka at gcc dot gnu dot org
  2005-10-30 21:59 ` hubicka at gcc dot gnu dot org
  16 siblings, 0 replies; 18+ messages in thread
From: hubicka at gcc dot gnu dot org @ 2005-10-30 18:18 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #14 from hubicka at gcc dot gnu dot org  2005-10-30 18:18 -------
Subject: Bug 24172

Author: hubicka
Date: Sun Oct 30 18:14:15 2005
New Revision: 106247

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=106247
Log:
        PR tree-optimization/24172
        * tree-inline.c (copy_body_r): Unshare the substituted value first.
        * g++.dg/tree-ssa/pr24172.C: New testcase.

Added:
    trunk/gcc/testsuite/g++.dg/tree-ssa/pr24172.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-inline.c


-- 


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


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

* [Bug tree-optimization/24172] [4.1 Regression] error: incorrect sharing of tree nodes
  2005-10-03  1:06 [Bug c++/24172] New: error: incorrect sharing of tree nodes kev dot gilbert at cdu dot edu dot au
                   ` (15 preceding siblings ...)
  2005-10-30 18:18 ` hubicka at gcc dot gnu dot org
@ 2005-10-30 21:59 ` hubicka at gcc dot gnu dot org
  16 siblings, 0 replies; 18+ messages in thread
From: hubicka at gcc dot gnu dot org @ 2005-10-30 21:59 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #15 from hubicka at gcc dot gnu dot org  2005-10-30 21:59 -------
Fixed by my patch


-- 

hubicka at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


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


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

end of thread, other threads:[~2005-10-30 21:59 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-10-03  1:06 [Bug c++/24172] New: error: incorrect sharing of tree nodes kev dot gilbert at cdu dot edu dot au
2005-10-03  1:10 ` [Bug tree-optimization/24172] [4.1 Regression] " pinskia at gcc dot gnu dot org
2005-10-03  1:13 ` pinskia at gcc dot gnu dot org
2005-10-03  1:26 ` pinskia at gcc dot gnu dot org
2005-10-03 16:54 ` pinskia at gcc dot gnu dot org
2005-10-03 22:00 ` janis187 at us dot ibm dot com
2005-10-04 10:44 ` rguenth at gcc dot gnu dot org
2005-10-04 11:00 ` rguenth at gcc dot gnu dot org
2005-10-04 12:53 ` pinskia at gcc dot gnu dot org
2005-10-04 12:56 ` hubicka at ucw dot cz
2005-10-04 13:42 ` rguenth at gcc dot gnu dot org
2005-10-07  9:05 ` rguenth at gcc dot gnu dot org
2005-10-13 15:56 ` pinskia at gcc dot gnu dot org
2005-10-21 11:07 ` steven at gcc dot gnu dot org
2005-10-21 12:19 ` rguenth at gcc dot gnu dot org
2005-10-27 21:18 ` hubicka at gcc dot gnu dot org
2005-10-30 18:18 ` hubicka at gcc dot gnu dot org
2005-10-30 21:59 ` hubicka 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).