From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2369 invoked by alias); 20 Mar 2012 15:56:56 -0000 Received: (qmail 2359 invoked by uid 22791); 20 Mar 2012 15:56:55 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Received: from mail-lpp01m010-f47.google.com (HELO mail-lpp01m010-f47.google.com) (209.85.215.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 20 Mar 2012 15:56:42 +0000 Received: by lagw12 with SMTP id w12so170417lag.20 for ; Tue, 20 Mar 2012 08:56:40 -0700 (PDT) MIME-Version: 1.0 Received: by 10.152.147.1 with SMTP id tg1mr255575lab.37.1332259000424; Tue, 20 Mar 2012 08:56:40 -0700 (PDT) Received: by 10.112.20.3 with HTTP; Tue, 20 Mar 2012 08:56:40 -0700 (PDT) In-Reply-To: <20120320031321.26D7E45EE81@webmail.sinamail.sina.com.cn> References: <20120320031321.26D7E45EE81@webmail.sinamail.sina.com.cn> Date: Tue, 20 Mar 2012 15:56:00 -0000 Message-ID: Subject: Re: A problem related to const rvalue From: Jonathan Wakely To: chmodexplorer@sina.com Cc: gcc@gcc.gnu.org Content-Type: text/plain; charset=ISO-8859-1 X-IsSubscribed: yes Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org X-SW-Source: 2012-03/txt/msg00316.txt.bz2 2012/3/20 : > 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&&)