public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/96647] New: Can't resolve pointer to overloaded member with auto return type
@ 2020-08-17 9:18 rustamabd at gmail dot com
2020-08-17 11:43 ` [Bug c++/96647] " ppalka at gcc dot gnu.org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: rustamabd at gmail dot com @ 2020-08-17 9:18 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96647
Bug ID: 96647
Summary: Can't resolve pointer to overloaded member with auto
return type
Product: gcc
Version: 10.2.0
Status: UNCONFIRMED
Keywords: rejects-valid
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: rustamabd at gmail dot com
Target Milestone: ---
auto return type in combination with overloading and CRTP results in an
overload set that cannot be disambiguated.
Example:
template<typename T>
struct Base {
auto f(int) { return static_cast<T*>(this); }
auto f(char) { return static_cast<T*>(this); }
};
struct A : Base<A> {};
int main() {
A instance;
// instance.f('x') // "fixes" the issue
auto ptr = static_cast<A* (A::*)(char)>(&A::f); // error here
(instance.*ptr)('x');
}
Error:
error: no matches converting function 'f' to type 'struct A* (struct
A::*)(char)'
14 | auto ptr = static_cast<A* (A::*)(char)>(&A::f); // error here
| ^
note: candidates are: 'auto Base<T>::f(char) [with T = A]'
4 | auto f(char) { return static_cast<T*>(this); }
| ^
note: 'auto Base<T>::f(int) [with T = A]'
3 | auto f(int) { return static_cast<T*>(this); }
| ^
Replacing "auto" with "T*", as well as invoking instance.f('x'), fixes the
issue.
clang compiles the code fine.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/96647] Can't resolve pointer to overloaded member with auto return type
2020-08-17 9:18 [Bug c++/96647] New: Can't resolve pointer to overloaded member with auto return type rustamabd at gmail dot com
@ 2020-08-17 11:43 ` ppalka at gcc dot gnu.org
2020-09-09 13:21 ` cvs-commit at gcc dot gnu.org
2020-09-09 14:28 ` ppalka at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: ppalka at gcc dot gnu.org @ 2020-08-17 11:43 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96647
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |ASSIGNED
Target Milestone|--- |11.0
CC| |ppalka at gcc dot gnu.org
Last reconfirmed| |2020-08-17
Assignee|unassigned at gcc dot gnu.org |ppalka at gcc dot gnu.org
Ever confirmed|0 |1
--- Comment #1 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Confirmed, not a regression.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/96647] Can't resolve pointer to overloaded member with auto return type
2020-08-17 9:18 [Bug c++/96647] New: Can't resolve pointer to overloaded member with auto return type rustamabd at gmail dot com
2020-08-17 11:43 ` [Bug c++/96647] " ppalka at gcc dot gnu.org
@ 2020-09-09 13:21 ` cvs-commit at gcc dot gnu.org
2020-09-09 14:28 ` ppalka at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-09-09 13:21 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96647
--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:
https://gcc.gnu.org/g:4e03e2e08b94f65f2be3db17f880c205ec262f87
commit r11-3075-g4e03e2e08b94f65f2be3db17f880c205ec262f87
Author: Patrick Palka <ppalka@redhat.com>
Date: Wed Sep 9 09:21:09 2020 -0400
c++: Fix resolving the address of overloaded pmf [PR96647]
In resolve_address_of_overloaded_function, currently only the second
pass over the overload set (which considers just the function templates
in the overload set) checks constraints and performs return type
deduction when necessary. But as the testcases below show, we need to
do the same when considering non-template functions during the first
pass.
gcc/cp/ChangeLog:
PR c++/96647
* class.c (resolve_address_of_overloaded_function): Check
constraints_satisfied_p and perform return-type deduction via
maybe_instantiate_decl when considering non-template functions
in the overload set.
* cp-tree.h (maybe_instantiate_decl): Declare.
* decl2.c (maybe_instantiate_decl): Remove static.
gcc/testsuite/ChangeLog:
PR c++/96647
* g++.dg/cpp0x/auto-96647.C: New test.
* g++.dg/cpp0x/error9.C: New test.
* g++.dg/cpp2a/concepts-fn6.C: New test.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/96647] Can't resolve pointer to overloaded member with auto return type
2020-08-17 9:18 [Bug c++/96647] New: Can't resolve pointer to overloaded member with auto return type rustamabd at gmail dot com
2020-08-17 11:43 ` [Bug c++/96647] " ppalka at gcc dot gnu.org
2020-09-09 13:21 ` cvs-commit at gcc dot gnu.org
@ 2020-09-09 14:28 ` ppalka at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: ppalka at gcc dot gnu.org @ 2020-09-09 14:28 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96647
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
--- Comment #3 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed for GCC 11. Thanks for the report!
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-09-09 14:28 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-17 9:18 [Bug c++/96647] New: Can't resolve pointer to overloaded member with auto return type rustamabd at gmail dot com
2020-08-17 11:43 ` [Bug c++/96647] " ppalka at gcc dot gnu.org
2020-09-09 13:21 ` cvs-commit at gcc dot gnu.org
2020-09-09 14:28 ` ppalka 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).