This is the mail archive of the gcc@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]

Re: A problem related to const rvalue


2012/3/20  <chmodexplorer@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&&)


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