[Bug c++/19199] [3.3/3.4/4.0/4.1 Regression] Wrong warning about returning a reference to a temporary
Mark Mitchell
mark@codesourcery.com
Mon Mar 7 18:50:00 GMT 2005
Roger Sayle wrote:
> On Mon, 7 Mar 2005, Mark Mitchell wrote:
>
>>Roger Sayle wrote:
>>
>>>I truly hope you're not trying to suggest that it was me that introduced
>>>the concept of MIN_EXPR and MAX_EXPR as lvalues into the C++ front-end:
>>
>>I thought you were the person who introduced changes to fold that caused
>>it to generate these expressions when the GNU source extension did not
>>appear. Anyhow, who did what to whom isn't important. :-)
>
> I do appreciate the smiley, but I still feel unfairly maligned by such
> accusations.
Am I incorrect about the fact that you introduced the changes to fold?
If so, I humbly retract all previous maligning, and acknowledge the
unfairness thereof. If not, then that change probably introduced this
regression. But, I'm still not meaning to malign; until I've introduced
zero regressions in my last thousand patches, who am I to talk?
If I seem frustruated, it's simply because we seem to be running into
this issue again, after attempting to fix it before. That's my fault; I
wasn't comfortable with the fix you came up with for 7503, but instead
of pushing on that issue, I went along with build_modify_expr change to
reconsitute COND_EXPRs after the fact.
The way I think about this is that G++ has long supported the GNU
min/max expression extension -- and it's long been broken. Over the
years, I've fielded several bug reports about that extension, and we've
gradually cleaned it up, but mostly it's just been neglected. I think
that you probably got fooled by the fact that the code is there into
thinking that it works. :-) (I wouldn't be surprised if it works well
today, but I'd also not be surprised if it doesn't work. It certainly
didn't work reliably at the time of the original CVS import.)
I think that the simplest, most reliable, short-term change is to
disable this particular optimization in fold, only for C++. That's not
an ideal solution. If you can come up with a better approach that
doesn't involve disabling the optimization, that's great -- but I think
we need to convince ourselves that it handles all the cases. (I
actually think that your MIN_EXPR-is-a-canonical-form-of-COND_EXPR
argument can be made to work -- but you need to push the
build_modify_expr logic into more places.) In the long term, moving
fold until after the front end has done its thing, is the right way to go.
--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com
(916) 791-8304
More information about the Gcc
mailing list