public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/43525]  New: Useless condition: "if (__x->_M_right != __y)"
@ 2010-03-25 19:26 ninive at gmx dot at
  2010-03-25 20:44 ` [Bug libstdc++/43525] " paolo dot carlini at oracle dot com
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: ninive at gmx dot at @ 2010-03-25 19:26 UTC (permalink / raw)
  To: gcc-bugs

The variable "__y" in _Rb_tree_increment (src/tree.cc) is always equal to
"__x->_M_parent. Therefore the condition means (which is alwys true):

if (__x->_M_right != __x->_M_parent)

The source:

  _Rb_tree_node_base*
  _Rb_tree_increment(_Rb_tree_node_base* __x) throw ()
  {
    if (__x->_M_right != 0) 
      {
        __x = __x->_M_right;
        while (__x->_M_left != 0)
          __x = __x->_M_left;
      }
    else 
      {
        _Rb_tree_node_base* __y = __x->_M_parent;      // y == x->parent
        while (__x == __y->_M_right) 
          {
            __x = __y;
            __y = __y->_M_parent;                 // y == x->parent
          }
        if (__x->_M_right != __y)    // if( x->right != x->parent )
          __x = __y;
      }
    return __x;
  }


-- 
           Summary: Useless condition: "if (__x->_M_right != __y)"
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ninive at gmx dot at


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


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

* [Bug libstdc++/43525] Useless condition: "if (__x->_M_right != __y)"
  2010-03-25 19:26 [Bug libstdc++/43525] New: Useless condition: "if (__x->_M_right != __y)" ninive at gmx dot at
@ 2010-03-25 20:44 ` paolo dot carlini at oracle dot com
  2010-03-25 21:05 ` paolo dot carlini at oracle dot com
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: paolo dot carlini at oracle dot com @ 2010-03-25 20:44 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from paolo dot carlini at oracle dot com  2010-03-25 20:44 -------
Makes sense. I'm still a bit reluctant to change this for 4.5.0. The last time
we improved a bit the RB tree implementation we compared it to the one used in
the Linux kernel, can you do it and confirm?


-- 

paolo dot carlini at oracle dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |paolo dot carlini at oracle
                   |                            |dot com
           Severity|normal                      |enhancement


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


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

* [Bug libstdc++/43525] Useless condition: "if (__x->_M_right != __y)"
  2010-03-25 19:26 [Bug libstdc++/43525] New: Useless condition: "if (__x->_M_right != __y)" ninive at gmx dot at
  2010-03-25 20:44 ` [Bug libstdc++/43525] " paolo dot carlini at oracle dot com
@ 2010-03-25 21:05 ` paolo dot carlini at oracle dot com
  2010-03-25 21:31 ` ninive at gmx dot at
  2010-03-25 21:38 ` paolo dot carlini at oracle dot com
  3 siblings, 0 replies; 5+ messages in thread
From: paolo dot carlini at oracle dot com @ 2010-03-25 21:05 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from paolo dot carlini at oracle dot com  2010-03-25 21:04 -------
Evidently, the condition isn't always true: if I replace it with a call to
__builtin_abort() when __x->_M_right == __y then
21_strings/basic_string/requirements/exception/generation_prohibited.cc aborts.
I don't have the time to investigate now in detail what's going on but the PR
is certainly invalid.


-- 

paolo dot carlini at oracle dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


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


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

* [Bug libstdc++/43525] Useless condition: "if (__x->_M_right != __y)"
  2010-03-25 19:26 [Bug libstdc++/43525] New: Useless condition: "if (__x->_M_right != __y)" ninive at gmx dot at
  2010-03-25 20:44 ` [Bug libstdc++/43525] " paolo dot carlini at oracle dot com
  2010-03-25 21:05 ` paolo dot carlini at oracle dot com
@ 2010-03-25 21:31 ` ninive at gmx dot at
  2010-03-25 21:38 ` paolo dot carlini at oracle dot com
  3 siblings, 0 replies; 5+ messages in thread
From: ninive at gmx dot at @ 2010-03-25 21:31 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from ninive at gmx dot at  2010-03-25 21:30 -------
Hi Paolo,
Yes, you are right, I forgot the NULL value.
Sorry for disturbing.


-- 


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


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

* [Bug libstdc++/43525] Useless condition: "if (__x->_M_right != __y)"
  2010-03-25 19:26 [Bug libstdc++/43525] New: Useless condition: "if (__x->_M_right != __y)" ninive at gmx dot at
                   ` (2 preceding siblings ...)
  2010-03-25 21:31 ` ninive at gmx dot at
@ 2010-03-25 21:38 ` paolo dot carlini at oracle dot com
  3 siblings, 0 replies; 5+ messages in thread
From: paolo dot carlini at oracle dot com @ 2010-03-25 21:38 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from paolo dot carlini at oracle dot com  2010-03-25 21:38 -------
Ok. No problem.


-- 


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


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

end of thread, other threads:[~2010-03-25 21:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-25 19:26 [Bug libstdc++/43525] New: Useless condition: "if (__x->_M_right != __y)" ninive at gmx dot at
2010-03-25 20:44 ` [Bug libstdc++/43525] " paolo dot carlini at oracle dot com
2010-03-25 21:05 ` paolo dot carlini at oracle dot com
2010-03-25 21:31 ` ninive at gmx dot at
2010-03-25 21:38 ` paolo dot carlini at oracle dot com

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).