------- Additional Comments From rguenth at gcc dot gnu dot org  2005-05-15 
19:30 -------
This optimization should take place in

cp/typeck:build_indirect_ref

where it even tries to do so but fails because it does not strip
NOP_EXPRs before checking for the optimization and also because
same_types_p says const T and T are not equal.  Where we have a
MODIFY_EXPR(T, const T) and the const T coming from argument
conversion to operator=(const T&).  Maybe carrying out the
actual conversion for creating of the MODIFY_EXPR is not
necessary.

In build_indirect_ref we end up with sth like
(struct TD.1679 &) (struct TD.1679 *) &TARGET_EXPR <D.1693, operator+ (&bD.1689,
(struct TD.1679 &) (struct TD.1679 *) &cD.1690)>
when the only thing we are doing is a conversion from T& to const T&.

Deferred to someone knowing the C++ frontend - this optimization certainly
should take place there.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|FIXED                       |
            Summary|[4.0/4.1 Regression]        |g++.dg/opt/temp1.C should be
                   |g++.dg/opt/temp1.C execution|optimized elsewhere
                   |test fails                  |


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

Reply via email to