[Bug optimization/10823] [3.3/3.4 regression] wrong code after first cse pass

bangerth at dealii dot org gcc-bugzilla@gcc.gnu.org
Wed Jun 25 15:42:00 GMT 2003


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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


bangerth at dealii dot org changed:

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


------- Additional Comments From bangerth at dealii dot org  2003-06-25 15:14 -------
Your code is faulty: in this function
   LV get() const {
      return op(*static_cast<const ITP&>(*this), *second);
   }
the first operand to op.operator() is constructed by calling
   Uop::result_type Uev::operator* () const {
      return op(*p);
   }
with result_type being of type RV. Thus, it's returned object is a 
temporary. However, op.Bop::operator() takes a reference and passes
it on. This doesn't work.

I could make the code work as expected also in the presence of
strict aliasing, by replacing the first function above (in the
original code) by
   LV get() const {
     static RV rv = *static_cast<const ITP&>(*this);
     return op(rv, *second);
   }

I attach my last reduced testcase to the PR later.

W.



More information about the Gcc-bugs mailing list