public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/83417] Pointer-to-member template parameter with auto member type dependent container type does not work (C++17)
       [not found] <bug-83417-4@http.gcc.gnu.org/bugzilla/>
@ 2020-10-16 16:05 ` mpolacek at gcc dot gnu.org
  2021-01-27 14:36 ` davveston at gmail dot com
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 4+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-10-16 16:05 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
                 CC|                            |mpolacek at gcc dot gnu.org
   Last reconfirmed|                            |2020-10-16
     Ever confirmed|0                           |1

--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Confirmed.

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

* [Bug c++/83417] Pointer-to-member template parameter with auto member type dependent container type does not work (C++17)
       [not found] <bug-83417-4@http.gcc.gnu.org/bugzilla/>
  2020-10-16 16:05 ` [Bug c++/83417] Pointer-to-member template parameter with auto member type dependent container type does not work (C++17) mpolacek at gcc dot gnu.org
@ 2021-01-27 14:36 ` davveston at gmail dot com
  2021-02-03 10:01 ` davveston at gmail dot com
  2023-12-15 17:23 ` waffl3x at protonmail dot com
  3 siblings, 0 replies; 4+ messages in thread
From: davveston at gmail dot com @ 2021-01-27 14:36 UTC (permalink / raw)
  To: gcc-bugs

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

David Friberg <davveston at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |davveston at gmail dot com

--- Comment #3 from David Friberg <davveston at gmail dot com> ---
The same holds for the case of function pointers.

Given the following function:

 void f(int) {}

Both examples (A) and (B) below are well-formed, as per [temp.deduct.type]/13
(and for (B): also as per [temp.arg.nontype]/1).

 // Example (A)
 template <auto>
 struct A;

 template <typename T, void (*fp)(T)>
 struct A<fp> { };

 A<f> a{};  // #1: OK

 // Example (B)
 template <auto>
 struct B;

 template <typename T, auto (*fp)(T)>
 struct B<fp> { };

 B<f> b{};  // #2: Rejected (type deduction failure in partial specialization)

Clang accepts both, whereas GCC (trunk/any version I've tried that supports
C++17) rejects example (B), as #2 is resolved to the primary (non-defined)
class template after failing to deduce the dependent 'T' from 'auto (*fp)(T)'
in the partial specialization, given the argument 'f' to the latter (non-type)
template parameter.

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

* [Bug c++/83417] Pointer-to-member template parameter with auto member type dependent container type does not work (C++17)
       [not found] <bug-83417-4@http.gcc.gnu.org/bugzilla/>
  2020-10-16 16:05 ` [Bug c++/83417] Pointer-to-member template parameter with auto member type dependent container type does not work (C++17) mpolacek at gcc dot gnu.org
  2021-01-27 14:36 ` davveston at gmail dot com
@ 2021-02-03 10:01 ` davveston at gmail dot com
  2023-12-15 17:23 ` waffl3x at protonmail dot com
  3 siblings, 0 replies; 4+ messages in thread
From: davveston at gmail dot com @ 2021-02-03 10:01 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from David Friberg <davveston at gmail dot com> ---
The example of my previous comment may fall under (the original intent of?) CWG
1892. If so it ill-formed, as 'auto (*fp)(T)' is not a function declaration in
the template parameter list. 
http://open-std.org/JTC1/SC22/WG21/docs/cwg_defects.html#1892

Although afaict a pointer to function declarator is not a function declarator,
meaning [dcl.spec.auto]/2 may not apply here.
https://timsong-cpp.github.io/cppwp/n4861/dcl.spec.auto#2

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

* [Bug c++/83417] Pointer-to-member template parameter with auto member type dependent container type does not work (C++17)
       [not found] <bug-83417-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2021-02-03 10:01 ` davveston at gmail dot com
@ 2023-12-15 17:23 ` waffl3x at protonmail dot com
  3 siblings, 0 replies; 4+ messages in thread
From: waffl3x at protonmail dot com @ 2023-12-15 17:23 UTC (permalink / raw)
  To: gcc-bugs

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

waffl3x <waffl3x at protonmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |waffl3x at protonmail dot com

--- Comment #5 from waffl3x <waffl3x at protonmail dot com> ---
https://godbolt.org/z/Kxco7c5Es

Still not working in trunk, was it ever decided on whether or not this
is well-formed?

```
template<auto> struct C {};
template <typename T, typename U, U T::* V>
void zoink(C<V>) { }

struct S { int _m; };

void go() { zoink(C<&S::_m>{}); }
```
https://godbolt.org/z/ohG9ra5en
This is the workaround I would use, it has better ergonomics anyway. I
believe we should decide on whether this truly is a bug or not and if
not just simply close it.

Credit to Tsche for pointing this case out to me.

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

end of thread, other threads:[~2023-12-15 17:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-83417-4@http.gcc.gnu.org/bugzilla/>
2020-10-16 16:05 ` [Bug c++/83417] Pointer-to-member template parameter with auto member type dependent container type does not work (C++17) mpolacek at gcc dot gnu.org
2021-01-27 14:36 ` davveston at gmail dot com
2021-02-03 10:01 ` davveston at gmail dot com
2023-12-15 17:23 ` waffl3x at protonmail 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).