This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [Bug c++/19199] [3.3/3.4/4.0/4.1 Regression] Wrong warning about returning a reference to a temporary
On Mar 8, 2005, Richard Henderson <rth@redhat.com> wrote:
>> As has been described earlier on this thread, GCC has folded the C++
>> source "(a >= b ? a : b) = c" into "MAX_EXPR (a,b) = c" and equivalently
>> "(a > b ? a : b) = c" into "MAX_EXPR (b,a) = c" since the creation of
>> current CVS.
> Which, as we've been seeing in this thread, is also a mistake.
Not quite. The folding above is not a mistake at all, if all the
expressions are exactly as displayed. The problem occurs when we
turn:
((int)a > (int)b ? a : b) = c
into
(__typeof(a))(MAX_EXPR ((int)a, (int)b)) = c
and avoiding this kind of lvalue-dropping transformation is exactly
what the patch I proposed fixes.
--
Alexandre Oliva http://www.ic.unicamp.br/~oliva/
Red Hat Compiler Engineer aoliva@{redhat.com, gcc.gnu.org}
Free Software Evangelist oliva@{lsd.ic.unicamp.br, gnu.org}