2012/3/20 <chmodexplo...@sina.com>: > Is it a bug or by design? Who can answer the question for me?
This list is for discussing the development of GCC not for help using it, so this is the wrong mailing list for your question. It would be more appropriate on the gcc-help mailing list, please take an follow-up there, thanks. I believe G++ is correct, the relevant text is in [basic.lval] where the standard says that "Class prvalues can have cv-qualified types; non-class prvalues always have cv-unqualified types." The result of the function f2() is a prvalue, so has type int, with no const-qualification. If you repeat the experiment with functions returning a class type instead of int then you should see the behaviour you expect where f( f2() ) will call f(const X&&)