public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/59296] New: [c++11] ref-qualified member function is ambiguous
@ 2013-11-26  4:14 eric.niebler at gmail dot com
  2013-11-26 11:22 ` [Bug c++/59296] " redi at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: eric.niebler at gmail dot com @ 2013-11-26  4:14 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 59296
           Summary: [c++11] ref-qualified member function is ambiguous
           Product: gcc
           Version: 4.8.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: eric.niebler at gmail dot com

The following code fails to compile:

struct S
{
    constexpr int foo() const & { return 0; }
    constexpr int foo() const && { return 42; }
};

int main()
{
    constexpr int i = S{}.foo();
}

The error I get is:

$ /usr/local/gcc-4.8.2/bin/g++ -std=gnu++11 -c test.cpp
test.cpp: In function ‘int main()’:
test.cpp:9:31: error: call of overloaded ‘foo()’ is ambiguous
     constexpr int i = S{}.foo();
                               ^
test.cpp:9:31: note: candidates are:
test.cpp:3:19: note: constexpr int S::foo() const &
     constexpr int foo() const & { return 0; }
                   ^
test.cpp:4:19: note: constexpr int S::foo() const &&
     constexpr int foo() const && { return 42; }
                   ^

The code in question is not ambiguous. The object is clearly an rvalue, so the
&&-qualified member should be preferred.
>From gcc-bugs-return-435853-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Tue Nov 26 04:24:03 2013
Return-Path: <gcc-bugs-return-435853-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 3218 invoked by alias); 26 Nov 2013 04:24:02 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 3177 invoked by uid 48); 26 Nov 2013 04:23:55 -0000
From: "d.g.gorbachev at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug rtl-optimization/59179] [4.9 Regression] Wrong code generated with -Og
Date: Tue, 26 Nov 2013 04:24:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: rtl-optimization
X-Bugzilla-Version: 4.9.0
X-Bugzilla-Keywords: wrong-code
X-Bugzilla-Severity: normal
X-Bugzilla-Who: d.g.gorbachev at gmail dot com
X-Bugzilla-Status: RESOLVED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: 4.9.0
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_status resolution
Message-ID: <bug-59179-4-brqdqE3OvZ@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-59179-4@http.gcc.gnu.org/bugzilla/>
References: <bug-59179-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2013-11/txt/msg02630.txt.bz2
Content-length: 465

http://gcc.gnu.org/bugzilla/show_bug.cgi?idY179

Dmitry Gorbachev <d.g.gorbachev at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |RESOLVED
         Resolution|---                         |WORKSFORME

--- Comment #2 from Dmitry Gorbachev <d.g.gorbachev at gmail dot com> ---
GCC 4.9.0 20131124 - works.


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

* [Bug c++/59296] [c++11] ref-qualified member function is ambiguous
  2013-11-26  4:14 [Bug c++/59296] New: [c++11] ref-qualified member function is ambiguous eric.niebler at gmail dot com
@ 2013-11-26 11:22 ` redi at gcc dot gnu.org
  2014-03-26 18:52 ` redi at gcc dot gnu.org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: redi at gcc dot gnu.org @ 2013-11-26 11:22 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2013-11-26
     Ever confirmed|0                           |1


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

* [Bug c++/59296] [c++11] ref-qualified member function is ambiguous
  2013-11-26  4:14 [Bug c++/59296] New: [c++11] ref-qualified member function is ambiguous eric.niebler at gmail dot com
  2013-11-26 11:22 ` [Bug c++/59296] " redi at gcc dot gnu.org
@ 2014-03-26 18:52 ` redi at gcc dot gnu.org
  2014-03-26 18:54 ` redi at gcc dot gnu.org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: redi at gcc dot gnu.org @ 2014-03-26 18:52 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |paul at preney dot ca

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
*** Bug 60631 has been marked as a duplicate of this bug. ***


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

* [Bug c++/59296] [c++11] ref-qualified member function is ambiguous
  2013-11-26  4:14 [Bug c++/59296] New: [c++11] ref-qualified member function is ambiguous eric.niebler at gmail dot com
  2013-11-26 11:22 ` [Bug c++/59296] " redi at gcc dot gnu.org
  2014-03-26 18:52 ` redi at gcc dot gnu.org
@ 2014-03-26 18:54 ` redi at gcc dot gnu.org
  2014-06-18 21:00 ` jason at gcc dot gnu.org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: redi at gcc dot gnu.org @ 2014-03-26 18:54 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
reduced:

struct Type
{
  void get() const& { }
  void get() const&& { }
};

int main()
{
  Type{}.get();
}

The ambiguity happens when both overloads are const-qualified and *this is an
rvalue


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

* [Bug c++/59296] [c++11] ref-qualified member function is ambiguous
  2013-11-26  4:14 [Bug c++/59296] New: [c++11] ref-qualified member function is ambiguous eric.niebler at gmail dot com
                   ` (2 preceding siblings ...)
  2014-03-26 18:54 ` redi at gcc dot gnu.org
@ 2014-06-18 21:00 ` jason at gcc dot gnu.org
  2014-06-18 22:14 ` jason at gcc dot gnu.org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jason at gcc dot gnu.org @ 2014-06-18 21:00 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59296

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
                 CC|                            |jason at gcc dot gnu.org,
                   |                            |ville.voutilainen at gmail dot com
           Assignee|unassigned at gcc dot gnu.org      |jason at gcc dot gnu.org


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

* [Bug c++/59296] [c++11] ref-qualified member function is ambiguous
  2013-11-26  4:14 [Bug c++/59296] New: [c++11] ref-qualified member function is ambiguous eric.niebler at gmail dot com
                   ` (3 preceding siblings ...)
  2014-06-18 21:00 ` jason at gcc dot gnu.org
@ 2014-06-18 22:14 ` jason at gcc dot gnu.org
  2014-06-19  9:35 ` jason at gcc dot gnu.org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jason at gcc dot gnu.org @ 2014-06-18 22:14 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59296

--- Comment #3 from Jason Merrill <jason at gcc dot gnu.org> ---
Author: jason
Date: Wed Jun 18 22:13:51 2014
New Revision: 211809

URL: https://gcc.gnu.org/viewcvs?rev=211809&root=gcc&view=rev
Log:
    PR c++/59296
    * call.c (add_function_candidate): Set LOOKUP_NO_RVAL_BIND for
    ref-qualifier handling.

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


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

* [Bug c++/59296] [c++11] ref-qualified member function is ambiguous
  2013-11-26  4:14 [Bug c++/59296] New: [c++11] ref-qualified member function is ambiguous eric.niebler at gmail dot com
                   ` (4 preceding siblings ...)
  2014-06-18 22:14 ` jason at gcc dot gnu.org
@ 2014-06-19  9:35 ` jason at gcc dot gnu.org
  2014-06-19  9:36 ` jason at gcc dot gnu.org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jason at gcc dot gnu.org @ 2014-06-19  9:35 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59296

--- Comment #4 from Jason Merrill <jason at gcc dot gnu.org> ---
Author: jason
Date: Thu Jun 19 09:34:57 2014
New Revision: 211820

URL: https://gcc.gnu.org/viewcvs?rev=211820&root=gcc&view=rev
Log:
    PR c++/59296
    * call.c (add_function_candidate): Set LOOKUP_NO_RVAL_BIND
    |LOOKUP_NO_TEMP_BIND for ref-qualifier handling.

Added:
    branches/gcc-4_9-branch/gcc/testsuite/g++.dg/cpp0x/ref-qual15.C
Modified:
    branches/gcc-4_9-branch/gcc/cp/ChangeLog
    branches/gcc-4_9-branch/gcc/cp/call.c


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

* [Bug c++/59296] [c++11] ref-qualified member function is ambiguous
  2013-11-26  4:14 [Bug c++/59296] New: [c++11] ref-qualified member function is ambiguous eric.niebler at gmail dot com
                   ` (5 preceding siblings ...)
  2014-06-19  9:35 ` jason at gcc dot gnu.org
@ 2014-06-19  9:36 ` jason at gcc dot gnu.org
  2014-06-20 18:33 ` jason at gcc dot gnu.org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jason at gcc dot gnu.org @ 2014-06-19  9:36 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59296

--- Comment #5 from Jason Merrill <jason at gcc dot gnu.org> ---
Author: jason
Date: Thu Jun 19 09:36:09 2014
New Revision: 211821

URL: https://gcc.gnu.org/viewcvs?rev=211821&root=gcc&view=rev
Log:
    PR c++/59296
    * call.c (add_function_candidate): Also set LOOKUP_NO_TEMP_BIND.

Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/call.c


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

* [Bug c++/59296] [c++11] ref-qualified member function is ambiguous
  2013-11-26  4:14 [Bug c++/59296] New: [c++11] ref-qualified member function is ambiguous eric.niebler at gmail dot com
                   ` (6 preceding siblings ...)
  2014-06-19  9:36 ` jason at gcc dot gnu.org
@ 2014-06-20 18:33 ` jason at gcc dot gnu.org
  2014-06-20 18:35 ` jason at gcc dot gnu.org
  2014-11-19  9:59 ` paolo.carlini at oracle dot com
  9 siblings, 0 replies; 11+ messages in thread
From: jason at gcc dot gnu.org @ 2014-06-20 18:33 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59296

--- Comment #6 from Jason Merrill <jason at gcc dot gnu.org> ---
Author: jason
Date: Fri Jun 20 18:32:35 2014
New Revision: 211854

URL: https://gcc.gnu.org/viewcvs?rev=211854&root=gcc&view=rev
Log:
    PR c++/59296
    * call.c (add_function_candidate): Avoid special 'this' handling
    if we have a ref-qualifier.

Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/call.c


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

* [Bug c++/59296] [c++11] ref-qualified member function is ambiguous
  2013-11-26  4:14 [Bug c++/59296] New: [c++11] ref-qualified member function is ambiguous eric.niebler at gmail dot com
                   ` (7 preceding siblings ...)
  2014-06-20 18:33 ` jason at gcc dot gnu.org
@ 2014-06-20 18:35 ` jason at gcc dot gnu.org
  2014-11-19  9:59 ` paolo.carlini at oracle dot com
  9 siblings, 0 replies; 11+ messages in thread
From: jason at gcc dot gnu.org @ 2014-06-20 18:35 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59296

--- Comment #7 from Jason Merrill <jason at gcc dot gnu.org> ---
Author: jason
Date: Fri Jun 20 18:35:19 2014
New Revision: 211856

URL: https://gcc.gnu.org/viewcvs?rev=211856&root=gcc&view=rev
Log:
    PR c++/59296
    * call.c (add_function_candidate): Avoid special 'this' handling
    if we have a ref-qualifier.

Modified:
    branches/gcc-4_9-branch/gcc/cp/ChangeLog
    branches/gcc-4_9-branch/gcc/cp/call.c


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

* [Bug c++/59296] [c++11] ref-qualified member function is ambiguous
  2013-11-26  4:14 [Bug c++/59296] New: [c++11] ref-qualified member function is ambiguous eric.niebler at gmail dot com
                   ` (8 preceding siblings ...)
  2014-06-20 18:35 ` jason at gcc dot gnu.org
@ 2014-11-19  9:59 ` paolo.carlini at oracle dot com
  9 siblings, 0 replies; 11+ messages in thread
From: paolo.carlini at oracle dot com @ 2014-11-19  9:59 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59296

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
                 CC|jason at gcc dot gnu.org           |
         Resolution|---                         |FIXED
   Target Milestone|---                         |4.9.1

--- Comment #8 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Fixed for 4.9.1 then.


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

end of thread, other threads:[~2014-11-19  9:59 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-26  4:14 [Bug c++/59296] New: [c++11] ref-qualified member function is ambiguous eric.niebler at gmail dot com
2013-11-26 11:22 ` [Bug c++/59296] " redi at gcc dot gnu.org
2014-03-26 18:52 ` redi at gcc dot gnu.org
2014-03-26 18:54 ` redi at gcc dot gnu.org
2014-06-18 21:00 ` jason at gcc dot gnu.org
2014-06-18 22:14 ` jason at gcc dot gnu.org
2014-06-19  9:35 ` jason at gcc dot gnu.org
2014-06-19  9:36 ` jason at gcc dot gnu.org
2014-06-20 18:33 ` jason at gcc dot gnu.org
2014-06-20 18:35 ` jason at gcc dot gnu.org
2014-11-19  9:59 ` paolo.carlini at oracle dot com

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).