public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/106893] New: auto deduces wrong type for function pointer
@ 2022-09-08 21:53 dan at stahlke dot org
2022-09-08 22:07 ` [Bug c++/106893] [12/13 Regression] " pinskia at gcc dot gnu.org
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: dan at stahlke dot org @ 2022-09-08 21:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106893
Bug ID: 106893
Summary: auto deduces wrong type for function pointer
Product: gcc
Version: 12.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: dan at stahlke dot org
Target Milestone: ---
This works in 11.3.0 but not in 12.2.0.
struct IntegerCoordinate {
int x() const;
int y() const;
};
template <typename T>
struct CoordTraits
{
static auto GetX(T const &p) { return p.x(); }
static auto GetY(T const &p) { return p.y(); }
using Ordinate = decltype(GetX(T{}));
};
template <typename Traits>
struct Node {
static constexpr auto GetX = Traits::GetX; // works because of the `using
Ordinate = ...`
static constexpr auto GetY = Traits::GetY; // compilation error
// This compiles
//static constexpr auto GetX = &Traits::GetX;
//static constexpr auto GetY = &Traits::GetY;
// This compiles
//using fptr = int(*)(IntegerCoordinate const &);
//static constexpr fptr GetX = Traits::GetX;
//static constexpr fptr GetY = Traits::GetY;
// Not needed for minimal test case
auto x(auto const &p) const { return GetX(p); }
auto y(auto const &p) const { return GetY(p); }
};
int main() {
Node<CoordTraits<IntegerCoordinate>> node;
// Not needed for minimal test case
node.x(IntegerCoordinate{});
node.y(IntegerCoordinate{});
}
$ g++ -std=c++20 gcc-function-ptr-bug.cpp -c -o gcc-function-ptr-bug.o
gcc-function-ptr-bug.cpp: In instantiation of ‘constexpr auto (* const
Node<CoordTraits<IntegerCoordinate> >::GetY)(const IntegerCoordinate&)’:
gcc-function-ptr-bug.cpp:17:27: required from ‘struct
Node<CoordTraits<IntegerCoordinate> >’
gcc-function-ptr-bug.cpp:32:42: required from here
gcc-function-ptr-bug.cpp:17:27: error: invalid conversion from ‘int (*)(const
IntegerCoordinate&)’ to ‘auto (*)(const IntegerCoordinate&)’ [-fpermissive]
17 | static constexpr auto GetY = Traits::GetY; // compilation error
| ^~~~
| |
| int (*)(const IntegerCoordinate&)
gcc-function-ptr-bug.cpp: In instantiation of ‘auto Node<Traits>::y(const
auto:2&) const [with auto:2 = IntegerCoordinate; Traits =
CoordTraits<IntegerCoordinate>]’:
gcc-function-ptr-bug.cpp:35:11: required from here
gcc-function-ptr-bug.cpp:28:46: error: use of
‘Node<CoordTraits<IntegerCoordinate> >::GetY’ before deduction of ‘auto’
28 | auto y(auto const &p) const { return GetY(p); }
| ~~~~^~~
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/106893] [12/13 Regression] auto deduces wrong type for function pointer
2022-09-08 21:53 [Bug c++/106893] New: auto deduces wrong type for function pointer dan at stahlke dot org
@ 2022-09-08 22:07 ` pinskia at gcc dot gnu.org
2022-09-09 10:36 ` redi at gcc dot gnu.org
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-09-08 22:07 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106893
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
Target Milestone|--- |12.3
Summary|auto deduces wrong type for |[12/13 Regression] auto
|function pointer |deduces wrong type for
| |function pointer
Last reconfirmed| |2022-09-08
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Reduced testcase:
template <typename T>
struct CoordTraits
{
static auto GetX(T const &p) { return 1; }
};
typedef CoordTraits<int> Traits;
static constexpr auto GetX = Traits::GetX;
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/106893] [12/13 Regression] auto deduces wrong type for function pointer
2022-09-08 21:53 [Bug c++/106893] New: auto deduces wrong type for function pointer dan at stahlke dot org
2022-09-08 22:07 ` [Bug c++/106893] [12/13 Regression] " pinskia at gcc dot gnu.org
@ 2022-09-09 10:36 ` redi at gcc dot gnu.org
2022-09-12 17:28 ` jason at gcc dot gnu.org
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2022-09-09 10:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106893
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jason at gcc dot gnu.org
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Started with r12-1270:
c++: alias member template [PR100102]
Patrick already fixed the primary cause of this bug. But while I was
looking at this testcase I noticed that with the qualified name k::o we
ended up with a plain FUNCTION_DECL, whereas without the k:: we got a
BASELINK. There seems to be no good reason not to return the BASELINK
in this case as well.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/106893] [12/13 Regression] auto deduces wrong type for function pointer
2022-09-08 21:53 [Bug c++/106893] New: auto deduces wrong type for function pointer dan at stahlke dot org
2022-09-08 22:07 ` [Bug c++/106893] [12/13 Regression] " pinskia at gcc dot gnu.org
2022-09-09 10:36 ` redi at gcc dot gnu.org
@ 2022-09-12 17:28 ` jason at gcc dot gnu.org
2022-09-12 19:47 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: jason at gcc dot gnu.org @ 2022-09-12 17:28 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106893
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |jason at gcc dot gnu.org
Status|NEW |ASSIGNED
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/106893] [12/13 Regression] auto deduces wrong type for function pointer
2022-09-08 21:53 [Bug c++/106893] New: auto deduces wrong type for function pointer dan at stahlke dot org
` (2 preceding siblings ...)
2022-09-12 17:28 ` jason at gcc dot gnu.org
@ 2022-09-12 19:47 ` cvs-commit at gcc dot gnu.org
2022-09-12 20:30 ` [Bug c++/106893] [12 " cvs-commit at gcc dot gnu.org
2023-04-21 20:13 ` jason at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-09-12 19:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106893
--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jason Merrill <jason@gcc.gnu.org>:
https://gcc.gnu.org/g:03381beccb52c0e2c15da3b8b8dfa3bb6eb71df9
commit r13-2632-g03381beccb52c0e2c15da3b8b8dfa3bb6eb71df9
Author: Jason Merrill <jason@redhat.com>
Date: Mon Sep 12 13:47:34 2022 -0400
c++: auto member function and auto variable [PR106893]
As with PR105623, we need to call mark_single_function sooner to
resolve the type of a BASELINK.
PR c++/106893
PR c++/90451
gcc/cp/ChangeLog:
* decl.cc (cp_finish_decl): Call mark_single_function.
gcc/testsuite/ChangeLog:
* g++.dg/cpp1y/auto-fn65.C: New test.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/106893] [12 Regression] auto deduces wrong type for function pointer
2022-09-08 21:53 [Bug c++/106893] New: auto deduces wrong type for function pointer dan at stahlke dot org
` (3 preceding siblings ...)
2022-09-12 19:47 ` cvs-commit at gcc dot gnu.org
@ 2022-09-12 20:30 ` cvs-commit at gcc dot gnu.org
2023-04-21 20:13 ` jason at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-09-12 20:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106893
--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Jason Merrill
<jason@gcc.gnu.org>:
https://gcc.gnu.org/g:999638cb7b126d33d1ea6548c69ba387b7d7a270
commit r12-8758-g999638cb7b126d33d1ea6548c69ba387b7d7a270
Author: Jason Merrill <jason@redhat.com>
Date: Mon Sep 12 13:47:34 2022 -0400
c++: auto member function and auto variable [PR106893]
As with PR105623, we need to call mark_single_function sooner to
resolve the type of a BASELINK.
PR c++/106893
PR c++/90451
gcc/cp/ChangeLog:
* decl.cc (cp_finish_decl): Call mark_single_function.
gcc/testsuite/ChangeLog:
* g++.dg/cpp1y/auto-fn65.C: New test.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/106893] [12 Regression] auto deduces wrong type for function pointer
2022-09-08 21:53 [Bug c++/106893] New: auto deduces wrong type for function pointer dan at stahlke dot org
` (4 preceding siblings ...)
2022-09-12 20:30 ` [Bug c++/106893] [12 " cvs-commit at gcc dot gnu.org
@ 2023-04-21 20:13 ` jason at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: jason at gcc dot gnu.org @ 2023-04-21 20:13 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106893
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to work| |12.3.0, 13.0
Resolution|--- |FIXED
Status|ASSIGNED |RESOLVED
--- Comment #5 from Jason Merrill <jason at gcc dot gnu.org> ---
Fixed for 12.3/13.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2023-04-21 20:13 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-08 21:53 [Bug c++/106893] New: auto deduces wrong type for function pointer dan at stahlke dot org
2022-09-08 22:07 ` [Bug c++/106893] [12/13 Regression] " pinskia at gcc dot gnu.org
2022-09-09 10:36 ` redi at gcc dot gnu.org
2022-09-12 17:28 ` jason at gcc dot gnu.org
2022-09-12 19:47 ` cvs-commit at gcc dot gnu.org
2022-09-12 20:30 ` [Bug c++/106893] [12 " cvs-commit at gcc dot gnu.org
2023-04-21 20:13 ` 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).