This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]