From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16648 invoked by alias); 17 Jun 2011 17:59:46 -0000 Received: (qmail 16633 invoked by uid 22791); 17 Jun 2011 17:59:45 -0000 X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,TW_CX,TW_GC X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 17 Jun 2011 17:59:31 +0000 From: "hstong at ca dot ibm.com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/49458] New: [C++0x] Obvious candidate for conversion to function lvalue rejected X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: hstong at ca dot ibm.com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Date: Fri, 17 Jun 2011 17:59:00 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2011-06/txt/msg01604.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D49458 Summary: [C++0x] Obvious candidate for conversion to function lvalue rejected Product: gcc Version: 4.6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned@gcc.gnu.org ReportedBy: hstong@ca.ibm.com CC: michaelw@ca.ibm.com Host: powerpc64-unknown-linux-gnu Target: powerpc64-unknown-linux-gnu According to the 2011 FCD, subclause 13.3.1.6 [over.match.ref] paragraph 1: >>> The conversion functions of S and its base classes are considered, except t= hat for copy-initialization, only the non-explicit conversion functions are considered. Those that are not hidden within S and yield type "lvalue refer= ence to cv2 T2" (when 8.5.3 requires an lvalue result) or "cv2 T2" or "rvalue reference to cv2 T2" (when 8.5.3 requires an rvalue result), where "cv1 T" is reference-compatible (8.5.3) with "cv2 T2", are candidate functi= ons. <<< Both lvalue references and rvalue references to function types require bind= ing to function lvalues. The following test case is expected to compile clean. GCC still does not compile if #1 is commented out. GCC will compile if #2 is commented out, but that behaviour is unsupported = by the referenced wording. In particular, #2 should be a candidate and (from the wording) #1 is not for conversion to a function lvalue. ### Self-contained source (a.cpp):> cat a.cpp typedef void ftype(); void foo() { } struct A { operator ftype&&(void); // #1 operator ftype&(void) { return foo; } // #2 }; ftype &&frvref =3D A(); ### Compiler invocation: g++-4.6.0 -std=3Dc++0x -o a.o -c a.cpp ### Compiler output: a.cpp:9:20: error: invalid initialization of reference of type =E2=80=98voi= d (&&)()=E2=80=99 from expression of type =E2=80=98A=E2=80=99 ### g++ -v output:> g++-4.6.0 -v Using built-in specs. COLLECT_GCC=3Dg++-4.6.0 COLLECT_LTO_WRAPPER=3D/data/gcc/libexec/gcc/powerpc64-unknown-linux-gnu/4.6= .0/lto-wrapper Target: powerpc64-unknown-linux-gnu Configured with: ./configure --prefix=3D/data/gcc --program-suffix=3D-4.6.0 --disable-libssp --disable-libgcj --enable-version-specific-runtime-libs --with-cpu=3Ddefault32 --enable-secureplt --with-long-double-128 --enable-s= hared --enable-__cxa_atexit --enable-threads=3Dposix --enable-languages=3Dc,c++,f= ortran --with-gmp=3D/usr/local Thread model: posix gcc version 4.6.0 (GCC)