public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/49458] New: [C++0x] Obvious candidate for conversion to function lvalue rejected
@ 2011-06-17 17:59 hstong at ca dot ibm.com
  2011-06-17 20:45 ` [Bug c++/49458] " jason at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: hstong at ca dot ibm.com @ 2011-06-17 17:59 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49458

           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 that
for copy-initialization, only the non-explicit conversion functions are
considered. Those that are not hidden within S and yield type "lvalue reference
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 functions.
<<<

Both lvalue references and rvalue references to function types require binding
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 = A();


### Compiler invocation:
g++-4.6.0 -std=c++0x -o a.o -c a.cpp


### Compiler output:
a.cpp:9:20: error: invalid initialization of reference of type ‘void (&&)()’
from expression of type ‘A’


### g++ -v output:> g++-4.6.0 -v
Using built-in specs.
COLLECT_GCC=g++-4.6.0
COLLECT_LTO_WRAPPER=/data/gcc/libexec/gcc/powerpc64-unknown-linux-gnu/4.6.0/lto-wrapper
Target: powerpc64-unknown-linux-gnu
Configured with: ./configure --prefix=/data/gcc --program-suffix=-4.6.0
--disable-libssp --disable-libgcj --enable-version-specific-runtime-libs
--with-cpu=default32 --enable-secureplt --with-long-double-128 --enable-shared
--enable-__cxa_atexit --enable-threads=posix --enable-languages=c,c++,fortran
--with-gmp=/usr/local
Thread model: posix
gcc version 4.6.0 (GCC)


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/49458] [C++0x] Obvious candidate for conversion to function lvalue rejected
  2011-06-17 17:59 [Bug c++/49458] New: [C++0x] Obvious candidate for conversion to function lvalue rejected hstong at ca dot ibm.com
@ 2011-06-17 20:45 ` jason at gcc dot gnu.org
  2011-06-18  5:58 ` jason at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: jason at gcc dot gnu.org @ 2011-06-17 20:45 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49458

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2011.06.17 20:44:28
                 CC|                            |jason at gcc dot gnu.org
         AssignedTo|unassigned at gcc dot       |jason at gcc dot gnu.org
                   |gnu.org                     |
     Ever Confirmed|0                           |1

--- Comment #1 from Jason Merrill <jason at gcc dot gnu.org> 2011-06-17 20:44:28 UTC ---
I agree that #2 should be a candidate, since it returns a function lvalue, and
frvref can bind to a function lvalue.  That is a bug.

I also agree with your interpretation of the standard on the other points, but
that seems unintentional, so I'm going to raise the issue with the committee.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/49458] [C++0x] Obvious candidate for conversion to function lvalue rejected
  2011-06-17 17:59 [Bug c++/49458] New: [C++0x] Obvious candidate for conversion to function lvalue rejected hstong at ca dot ibm.com
  2011-06-17 20:45 ` [Bug c++/49458] " jason at gcc dot gnu.org
@ 2011-06-18  5:58 ` jason at gcc dot gnu.org
  2011-09-05  4:34 ` jason at gcc dot gnu.org
  2011-09-05 15:48 ` [Bug c++/49458] [C++0x][DR 1328] " jason at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: jason at gcc dot gnu.org @ 2011-06-18  5:58 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49458

--- Comment #2 from Jason Merrill <jason at gcc dot gnu.org> 2011-06-18 05:58:42 UTC ---
Author: jason
Date: Sat Jun 18 05:58:38 2011
New Revision: 175164

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=175164
Log:
    PR c++/49458
    * call.c (convert_class_to_reference_1): Allow binding function
    lvalue to rvalue reference.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/rv-func2.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/call.c
    trunk/gcc/testsuite/ChangeLog


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/49458] [C++0x] Obvious candidate for conversion to function lvalue rejected
  2011-06-17 17:59 [Bug c++/49458] New: [C++0x] Obvious candidate for conversion to function lvalue rejected hstong at ca dot ibm.com
  2011-06-17 20:45 ` [Bug c++/49458] " jason at gcc dot gnu.org
  2011-06-18  5:58 ` jason at gcc dot gnu.org
@ 2011-09-05  4:34 ` jason at gcc dot gnu.org
  2011-09-05 15:48 ` [Bug c++/49458] [C++0x][DR 1328] " jason at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: jason at gcc dot gnu.org @ 2011-09-05  4:34 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49458

--- Comment #3 from Jason Merrill <jason at gcc dot gnu.org> 2011-09-05 04:33:54 UTC ---
Author: jason
Date: Mon Sep  5 04:33:48 2011
New Revision: 178520

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=178520
Log:
    PR c++/49267
    PR c++/49458
    DR 1328
    * call.c (reference_binding): Set rvaluedness_matches_p properly
    for reference to function conversion ops.
    (compare_ics): Adjust.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/rv-conv1.C
    trunk/gcc/testsuite/g++.dg/cpp0x/rv-func3.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/call.c
    trunk/gcc/testsuite/ChangeLog


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/49458] [C++0x][DR 1328] Obvious candidate for conversion to function lvalue rejected
  2011-06-17 17:59 [Bug c++/49458] New: [C++0x] Obvious candidate for conversion to function lvalue rejected hstong at ca dot ibm.com
                   ` (2 preceding siblings ...)
  2011-09-05  4:34 ` jason at gcc dot gnu.org
@ 2011-09-05 15:48 ` jason at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: jason at gcc dot gnu.org @ 2011-09-05 15:48 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49458

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.7.0
            Summary|[C++0x] Obvious candidate   |[C++0x][DR 1328] Obvious
                   |for conversion to function  |candidate for conversion to
                   |lvalue rejected             |function lvalue rejected

--- Comment #4 from Jason Merrill <jason at gcc dot gnu.org> 2011-09-05 15:47:19 UTC ---
Core decided for issue 1328 to allow the lvalue reference conversion, but
prefer the rvalue reference conversion.  Implemented for 4.7.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-09-05 15:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-17 17:59 [Bug c++/49458] New: [C++0x] Obvious candidate for conversion to function lvalue rejected hstong at ca dot ibm.com
2011-06-17 20:45 ` [Bug c++/49458] " jason at gcc dot gnu.org
2011-06-18  5:58 ` jason at gcc dot gnu.org
2011-09-05  4:34 ` jason at gcc dot gnu.org
2011-09-05 15:48 ` [Bug c++/49458] [C++0x][DR 1328] " jason at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).